<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Activiti7工作流讲义 | 浪飞IT小栈</title>
    <meta name="generator" content="VuePress 1.9.9">
    <link rel="icon" href="/img/favicon.ico">
    <meta name="description" content="前后端技术分享">
    <meta name="keywords" content="前端博客,后端博客,人工智能,个人技术博客,前端,前端开发,前端框架,web前端,前端面试题,技术文档,学习,面试,JavaScript,js,ES6,TypeScript,vue,python,css3,html5,Node,git,github,markdown,java,Spring,Springboot,Redis,mysql">
    <meta name="baidu-site-verification" content="7F55weZDDc">
    <meta name="theme-color" content="#11a8cd">
    
    <link rel="preload" href="/assets/css/0.styles.ada71c49.css" as="style"><link rel="preload" href="/assets/js/app.a2a00aa5.js" as="script"><link rel="preload" href="/assets/js/2.256f807a.js" as="script"><link rel="preload" href="/assets/js/67.f36b2f7d.js" as="script"><link rel="prefetch" href="/assets/js/10.ab144fe3.js"><link rel="prefetch" href="/assets/js/11.062e0879.js"><link rel="prefetch" href="/assets/js/12.f9c60882.js"><link rel="prefetch" href="/assets/js/13.0a6ebfcf.js"><link rel="prefetch" href="/assets/js/14.03fc6f12.js"><link rel="prefetch" href="/assets/js/15.19dbf9fd.js"><link rel="prefetch" href="/assets/js/16.6e68160b.js"><link rel="prefetch" href="/assets/js/17.1d678834.js"><link rel="prefetch" href="/assets/js/18.4536fd5c.js"><link rel="prefetch" href="/assets/js/19.9c1b65df.js"><link rel="prefetch" href="/assets/js/20.c5f96e71.js"><link rel="prefetch" href="/assets/js/21.3f0b334e.js"><link rel="prefetch" href="/assets/js/22.55c868be.js"><link rel="prefetch" href="/assets/js/23.91286241.js"><link rel="prefetch" href="/assets/js/24.c1af1909.js"><link rel="prefetch" href="/assets/js/25.a995a755.js"><link rel="prefetch" href="/assets/js/26.abc5dea3.js"><link rel="prefetch" href="/assets/js/27.1eb62850.js"><link rel="prefetch" href="/assets/js/28.b383a871.js"><link rel="prefetch" href="/assets/js/29.088e0d73.js"><link rel="prefetch" href="/assets/js/3.cd716564.js"><link rel="prefetch" href="/assets/js/30.3ccc98d5.js"><link rel="prefetch" href="/assets/js/31.aab7cc23.js"><link rel="prefetch" href="/assets/js/32.5e16b7e6.js"><link rel="prefetch" href="/assets/js/33.4aaeb741.js"><link rel="prefetch" href="/assets/js/34.45e8e898.js"><link rel="prefetch" href="/assets/js/35.5899c97a.js"><link rel="prefetch" href="/assets/js/36.32e2e263.js"><link rel="prefetch" href="/assets/js/37.c4e27bbd.js"><link rel="prefetch" href="/assets/js/38.fe5e60d2.js"><link rel="prefetch" href="/assets/js/39.2cb0b4ee.js"><link rel="prefetch" href="/assets/js/4.edf4d5e7.js"><link rel="prefetch" href="/assets/js/40.08d5bead.js"><link rel="prefetch" href="/assets/js/41.2f80f24b.js"><link rel="prefetch" href="/assets/js/42.43a49913.js"><link rel="prefetch" href="/assets/js/43.08da7ec2.js"><link rel="prefetch" href="/assets/js/44.7c7cb8a9.js"><link rel="prefetch" href="/assets/js/45.0ddf7e7f.js"><link rel="prefetch" href="/assets/js/46.7c4609a5.js"><link rel="prefetch" href="/assets/js/47.edf3ddf8.js"><link rel="prefetch" href="/assets/js/48.569a90b9.js"><link rel="prefetch" href="/assets/js/49.fa368ac8.js"><link rel="prefetch" href="/assets/js/5.24054156.js"><link rel="prefetch" href="/assets/js/50.b9b3ea7f.js"><link rel="prefetch" href="/assets/js/51.a2ebf0fe.js"><link rel="prefetch" href="/assets/js/52.31f02238.js"><link rel="prefetch" href="/assets/js/53.4110ef1e.js"><link rel="prefetch" href="/assets/js/54.dab741c7.js"><link rel="prefetch" href="/assets/js/55.f27984e9.js"><link rel="prefetch" href="/assets/js/56.bd4c1a8e.js"><link rel="prefetch" href="/assets/js/57.375d40cb.js"><link rel="prefetch" href="/assets/js/58.932e3864.js"><link rel="prefetch" href="/assets/js/59.e657be1b.js"><link rel="prefetch" href="/assets/js/6.b259c061.js"><link rel="prefetch" href="/assets/js/60.88d94274.js"><link rel="prefetch" href="/assets/js/61.fa71d884.js"><link rel="prefetch" href="/assets/js/62.a9d3b3b7.js"><link rel="prefetch" href="/assets/js/63.f849fe75.js"><link rel="prefetch" href="/assets/js/64.1770f7a9.js"><link rel="prefetch" href="/assets/js/65.6afc33db.js"><link rel="prefetch" href="/assets/js/66.799f2eb4.js"><link rel="prefetch" href="/assets/js/68.868cd00b.js"><link rel="prefetch" href="/assets/js/69.4c29b907.js"><link rel="prefetch" href="/assets/js/7.e34ea00f.js"><link rel="prefetch" href="/assets/js/70.1b993ed4.js"><link rel="prefetch" href="/assets/js/71.e16ad4f9.js"><link rel="prefetch" href="/assets/js/72.627505e6.js"><link rel="prefetch" href="/assets/js/73.32768e14.js"><link rel="prefetch" href="/assets/js/74.968a580d.js"><link rel="prefetch" href="/assets/js/75.42d5af3d.js"><link rel="prefetch" href="/assets/js/76.19a69d31.js"><link rel="prefetch" href="/assets/js/77.cf627a78.js"><link rel="prefetch" href="/assets/js/78.07177880.js"><link rel="prefetch" href="/assets/js/8.c4dd00ce.js"><link rel="prefetch" href="/assets/js/9.0ff73be2.js">
    <link rel="stylesheet" href="/assets/css/0.styles.ada71c49.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/img/logo.png" alt="浪飞IT小栈" class="logo"> <span class="site-name can-hide">浪飞IT小栈</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><a href="/pages/6138ae/" class="nav-link">Java速通</a></div><div class="nav-item"><a href="/pages/705b35/" class="nav-link">面试经典</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="精品项目" class="dropdown-title"><a href="/project/" class="link-title">精品项目</a> <span class="title" style="display:none;">精品项目</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>桌面端</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/pages/8143cc480faf9a11/" class="nav-link">JavaScript</a></li></ul></li><li class="dropdown-item"><h4>PC后端</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/note/javascript/" class="nav-link">项目1</a></li><li class="dropdown-subitem"><a href="/note/typescript-axios/" class="nav-link">项目二</a></li></ul></li></ul></div></div><div class="nav-item"><a href="/about/" class="nav-link">电子书</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="索引" class="dropdown-title"><a href="/archives/" class="link-title">索引</a> <span class="title" style="display:none;">索引</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/" class="nav-link">分类</a></li><li class="dropdown-item"><!----> <a href="/tags/" class="nav-link">标签</a></li><li class="dropdown-item"><!----> <a href="/archives/" class="nav-link">归档</a></li></ul></div></div><div class="nav-item"><a href="/pages/0c07b2/" class="nav-link">IT杂货铺</a></div><div class="nav-item"><a href="/archives/" class="nav-link">更多资源</a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><div class="blogger"><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/avatar.jpg"> <div class="blogger-info"><h3>浪飞yes</h3> <span>无法简单的人儿~</span></div></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><a href="/pages/6138ae/" class="nav-link">Java速通</a></div><div class="nav-item"><a href="/pages/705b35/" class="nav-link">面试经典</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="精品项目" class="dropdown-title"><a href="/project/" class="link-title">精品项目</a> <span class="title" style="display:none;">精品项目</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>桌面端</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/pages/8143cc480faf9a11/" class="nav-link">JavaScript</a></li></ul></li><li class="dropdown-item"><h4>PC后端</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/note/javascript/" class="nav-link">项目1</a></li><li class="dropdown-subitem"><a href="/note/typescript-axios/" class="nav-link">项目二</a></li></ul></li></ul></div></div><div class="nav-item"><a href="/about/" class="nav-link">电子书</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="索引" class="dropdown-title"><a href="/archives/" class="link-title">索引</a> <span class="title" style="display:none;">索引</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/" class="nav-link">分类</a></li><li class="dropdown-item"><!----> <a href="/tags/" class="nav-link">标签</a></li><li class="dropdown-item"><!----> <a href="/archives/" class="nav-link">归档</a></li></ul></div></div><div class="nav-item"><a href="/pages/0c07b2/" class="nav-link">IT杂货铺</a></div><div class="nav-item"><a href="/archives/" class="nav-link">更多资源</a></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>开篇</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>基础语法</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>面向对象</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>常用类</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>基础高级</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>数据库</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>前端技术</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>热门框架</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>前后端分离</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>权限控制</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>NoSQL</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>微服务</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>消息中间件</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading"><span>脚手架</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>技术增值</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/9e54ff/" aria-current="page" class="active sidebar-link">Activiti7工作流讲义</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level2"><a href="/pages/9e54ff/#一、今日学习内容与目标" class="sidebar-link">一、今日学习内容与目标</a></li><li class="sidebar-sub-header level2"><a href="/pages/9e54ff/#二、工作流介绍" class="sidebar-link">二、工作流介绍</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_2-1-概念" class="sidebar-link">2.1 概念</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_2-2-应用领域" class="sidebar-link">2.2 应用领域</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_2-3-适用的行业" class="sidebar-link">2.3 适用的行业</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_2-4-具体案例" class="sidebar-link">2.4 具体案例</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_2-5-什么是工作流引擎" class="sidebar-link">2.5 什么是工作流引擎</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/pages/9e54ff/#三、什么是activiti7" class="sidebar-link">三、什么是Activiti7？</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_3-1-概述" class="sidebar-link">3.1 概述</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_3-2-activiti7内部核心机制" class="sidebar-link">3.2 Activiti7内部核心机制</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_3-3-bpmn" class="sidebar-link">3.3 BPMN</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_3-4-activiti如何使用" class="sidebar-link">3.4 Activiti如何使用</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_3-4-1-整合activiti" class="sidebar-link">3.4.1 整合Activiti</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_3-4-2-业务流程建模" class="sidebar-link">3.4.2 业务流程建模</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_3-4-3-部署业务流程" class="sidebar-link">3.4.3 部署业务流程</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_3-4-4-启动流程实例" class="sidebar-link">3.4.4 启动流程实例</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_3-4-5-查询待办任务" class="sidebar-link">3.4.5 查询待办任务</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_3-4-6-处理待办任务" class="sidebar-link">3.4.6 处理待办任务</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_3-4-7-结束流程" class="sidebar-link">3.4.7 结束流程</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/pages/9e54ff/#四、activiti7环境" class="sidebar-link">四、Activiti7环境</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_4-1-开发环境" class="sidebar-link">4.1 开发环境</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_4-2-安装activiti流程设计器" class="sidebar-link">4.2 安装Activiti流程设计器</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_4-2-1-在线安装" class="sidebar-link">4.2.1 在线安装</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_4-2-2-本地安装" class="sidebar-link">4.2.2 本地安装</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_4-3-解决actibpm中文乱码" class="sidebar-link">4.3 解决actiBPM中文乱码</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_4-4-activiti支持的数据库" class="sidebar-link">4.4  Activiti支持的数据库</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/pages/9e54ff/#五、集成activiti7" class="sidebar-link">五、集成Activiti7</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_5-1-创建maven项目" class="sidebar-link">5.1 创建Maven项目</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_5-2-添加maven依赖" class="sidebar-link">5.2 添加Maven依赖</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_5-3-添加log4j日志配置" class="sidebar-link">5.3 添加log4j日志配置</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_5-4-添加核心配置文件" class="sidebar-link">5.4 添加核心配置文件</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_5-5-测试" class="sidebar-link">5.5 测试</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_5-6-数据库表的命名规则" class="sidebar-link">5.6 数据库表的命名规则</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/pages/9e54ff/#六、流程引擎api" class="sidebar-link">六、流程引擎API</a></li><li class="sidebar-sub-header level2"><a href="/pages/9e54ff/#七、activiti7入门" class="sidebar-link">七、Activiti7入门</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_7-1-业务流程建模" class="sidebar-link">7.1 业务流程建模</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_7-1-1-绘制流程图" class="sidebar-link">7.1.1 绘制流程图</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_7-1-2-指定任务负责人" class="sidebar-link">7.1.2 指定任务负责人</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_7-1-3-生成png格式流程图" class="sidebar-link">7.1.3 生成png格式流程图</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_7-2-部署流程定义" class="sidebar-link">7.2 部署流程定义</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_7-3-启动流程实例" class="sidebar-link">7.3 启动流程实例</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_7-4-任务查询" class="sidebar-link">7.4 任务查询</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_7-5-任务处理" class="sidebar-link">7.5 任务处理</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_7-6-添加审批意见" class="sidebar-link">7.6 添加审批意见</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_7-6-查看历史审批" class="sidebar-link">7.6 查看历史审批</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/pages/9e54ff/#八、activiti7进阶" class="sidebar-link">八、Activiti7进阶</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_8-1-流程定义相关" class="sidebar-link">8.1 流程定义相关</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-1-1-流程定义查询-act-re-procdef" class="sidebar-link">8.1.1 流程定义查询   actreprocdef</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-1-2-流程资源下载" class="sidebar-link">8.1.2 流程资源下载</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-1-3-流程定义删除" class="sidebar-link">8.1.3 流程定义删除</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_8-2-流程实例相关" class="sidebar-link">8.2 流程实例相关</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-2-1-什么是流程实例" class="sidebar-link">8.2.1 什么是流程实例</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-2-2-businesskey-业务标识" class="sidebar-link">8.2.2 BusinessKey（业务标识）</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-2-3-流程定义-实例挂起-激活" class="sidebar-link">8.2.3 流程定义/实例挂起/激活</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_8-3-任务分配负责人" class="sidebar-link">8.3 任务分配负责人</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-3-1-固定分配" class="sidebar-link">8.3.1 固定分配</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-3-2-uel表达式分配" class="sidebar-link">8.3.2 UEL表达式分配</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-3-3-监听器分配【拓展】" class="sidebar-link">8.3.3 监听器分配【拓展】</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_8-4-流程变量" class="sidebar-link">8.4 流程变量</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-4-1-什么是流程变量" class="sidebar-link">8.4.1 什么是流程变量？</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-4-2-流程变量类型" class="sidebar-link">8.4.2 流程变量类型</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-4-3-流程变量的作用域" class="sidebar-link">8.4.3 流程变量的作用域</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-4-4-流程变量的使用方法" class="sidebar-link">8.4.4 流程变量的使用方法</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-4-5-使用global变量控制流程" class="sidebar-link">8.4.5 使用global变量控制流程</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_8-5-任务候选人" class="sidebar-link">8.5 任务候选人</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-5-1-设置任务候选人" class="sidebar-link">8.5.1 设置任务候选人</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-5-2-部署-启动流程" class="sidebar-link">8.5.2 部署&amp;启动流程</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-5-3-查询候选人任务" class="sidebar-link">8.5.3 查询候选人任务</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-5-4-领取候选人任务" class="sidebar-link">8.5.4 领取候选人任务</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-5-4-完成任务" class="sidebar-link">8.5.4 完成任务</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_8-6-网关" class="sidebar-link">8.6 网关</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-6-1-排他网关" class="sidebar-link">8.6.1 排他网关</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-6-2-并行网关" class="sidebar-link">8.6.2 并行网关</a></li><li class="sidebar-sub-header level4"><a href="/pages/9e54ff/#_8-6-3-包含网关" class="sidebar-link">8.6.3 包含网关</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/pages/9e54ff/#九、api小结" class="sidebar-link">九、API小结</a></li><li class="sidebar-sub-header level2"><a href="/pages/9e54ff/#_10、小结与作业" class="sidebar-link">10、小结与作业</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_10-1-小结" class="sidebar-link">10.1 小结</a></li><li class="sidebar-sub-header level3"><a href="/pages/9e54ff/#_10-2-作业" class="sidebar-link">10.2 作业</a></li></ul></li></ul></li><li><a href="/pages/ca48f7/" class="sidebar-link">Git版本控制</a></li></ul></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><a href="/categories/?category=Java%E9%80%9F%E9%80%9A" title="分类" data-v-06225672>Java速通</a></li><li data-v-06225672><a href="/categories/?category=%E6%8A%80%E6%9C%AF%E5%A2%9E%E5%80%BC" title="分类" data-v-06225672>技术增值</a></li></ul> <div class="info" data-v-06225672><div title="作者" class="author iconfont icon-touxiang" data-v-06225672><a href="https://github.com/langfeiyes" target="_blank" title="作者" class="beLink" data-v-06225672>langfeiyes</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2024-03-11</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">Activiti7工作流讲义<!----></h1>  <div class="theme-vdoing-content content__default"><h1 id="activiti7-工作流"><a href="#activiti7-工作流" class="header-anchor">#</a> Activiti7 工作流</h1> <p><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20240311225605911.png" alt=""></p> <h2 id="一、今日学习内容与目标"><a href="#一、今日学习内容与目标" class="header-anchor">#</a> 一、今日学习内容与目标</h2> <ul><li><p>了解何为工作流</p></li> <li><p>Activiti7工作流程API</p></li> <li><p>Spring集成Activiti7</p></li> <li><p>Activiti7基本操作</p></li> <li><p>Activiti7网关</p></li> <li><p>项目集成Activiti7</p></li></ul> <p>学习框架的方法论</p> <ul><li>框架的概念--产出背景--解决什么问题---百度/chatgpt</li> <li>框架入门案例--尽可能简单--可用---百度/chatgpt/官网</li> <li>框架常用API--丰富对框架理解--拓展入门案例功能--开发中注意细节---百度/chatgpt/官网/各种视频</li> <li>项目集成(运用)---框架整合---运用注意要点----框架理解/项目业务理解----纯靠个人理解(经验)</li></ul> <h2 id="二、工作流介绍"><a href="#二、工作流介绍" class="header-anchor">#</a> 二、工作流介绍</h2> <h3 id="_2-1-概念"><a href="#_2-1-概念" class="header-anchor">#</a> 2.1 概念</h3> <p>工作流(Workflow)是指工作事项的活动流向顺序，也就是工作的规范和顺序，包括实际工作过程中的工作环节、步骤和程序；它主要解决的是“使在多个参与者之间按照某种预定义的规则自动进行传递文档、信息或任务的过程，从而实现某个预期的业务目标，或者促使此目标的实现”。</p> <p>通过“工作流”软件为某项工作、业务自定义一个工作流程后，可以对节点流转进行及时有效跟踪、了解，确保工作的规范化、透明度、可视化和可再现，同时减少时间延误和纸张浪费，降低后来者的学习和培训成本。</p> <p>也能基于工作流产生的各项数据提高量化统计、查询和报表工作的效率。进而帮管理者更专注于战略层面的事务。</p> <p>案例:  出差费用报销</p> <p>目标:  公司把出差费用转账到自己的账户中.</p> <p>参与人: 申请人、部门主管、总经理、财务</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210528180651468.png" alt=""></strong></p> <p>传递文件/执行任务</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210528181312090.png" alt=""></strong></p> <h3 id="_2-2-应用领域"><a href="#_2-2-应用领域" class="header-anchor">#</a> 2.2 应用领域</h3> <p>工作流应用领域有哪些？</p> <p>企业: 采购流程、合同审核流程</p> <p>客户: 客户电话投诉处理流程</p> <p>生活中: 住房贷款审批流程、办理身份证、办理准生手续</p> <p>行政: 出差审批、报销流程、请假审批、用车流程、会议室申请</p> <p>银行业: 信贷审批、信用卡发卡审批</p> <p>人事: 员工培训、绩效考核、职位变动</p> <h3 id="_2-3-适用的行业"><a href="#_2-3-适用的行业" class="header-anchor">#</a> 2.3 适用的行业</h3> <p>消费品行业，制造业，电信服务业，银证险等金融服务业，物流服务业，物业服务业，物业管理，大中型进出口贸易公司，政府事业机构，研究院所及教育服务业等，特别是大的跨国企业和集团公司。</p> <h3 id="_2-4-具体案例"><a href="#_2-4-具体案例" class="header-anchor">#</a> 2.4 具体案例</h3> <p>下面是钉钉上的【<strong>出差费用报销</strong>】工作流程</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210531151354924.png" alt=""></strong></p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210531151034268.png" alt=""></strong></p> <p>思考一个问题：上面流程实现，该怎么设计？</p> <p><strong>传统方案：手写实现</strong></p> <p>1.需要在发起申请的时候选择每个阶段由哪个人员进行审批(数据库需要记录)</p> <p>2.我们需要在数据库中设计一个状态的字段【主管审批0,总经理审批1,财务审批2】，主管审批通过之后把状态修改为总经理审批.(硬编码的方式)</p> <p>3.当流程处于主管审批时，只有角色为主管的用户才能看到这条审核数据.</p> <p>通过上面的描述，同学们会发现，我们要实现这个流程控制，我们需要大量的代码才能完成.【工作量大】</p> <p>而且如果流程发生改变的情况下,我们编写的代码也需要进行调整【不灵活】</p> <p><strong>省事方案：现成框架-工作流引擎</strong></p> <p>osworkflow、jbpm、activiti、flowable、camunda</p> <p>https://lowcode.blog.csdn.net/article/details/116405594</p> <h3 id="_2-5-什么是工作流引擎"><a href="#_2-5-什么是工作流引擎" class="header-anchor">#</a> 2.5 什么是工作流引擎</h3> <p>是一种按照预定义规则【需要符合BPMN规范】进行部署，将业务和节点的流程进行分离【特定形式进行关联】，</p> <p>实现节点的自动流转的工作流框架.</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/workflow.png" alt=""></strong></p> <p>1.需要将预定于的流程文件BPMN部署到工作流引擎中,会把节点,路径信息存储到数据库中.</p> <p>2.工作流引擎提供了大量的API对流程进行查询处理,细节都是对应用程序屏蔽的,大大提供开发效率</p> <p>3.业务逻辑的处理和流程的流转是分离的，是通过BusinessKey进行关联的.</p> <h2 id="三、什么是activiti7"><a href="#三、什么是activiti7" class="header-anchor">#</a> 三、什么是Activiti7？</h2> <h3 id="_3-1-概述"><a href="#_3-1-概述" class="header-anchor">#</a> 3.1 概述</h3> <ul><li>Alfresco 软件在 2010 年 5 月 17 日宣布 Activiti 业务流程管理（BPM）开源项目的正式启动， 其
首席架构师由业务流程管理 BPM 的专家 Tom Baeyens 担任， Tom Baeyens 就是原来 jbpm 的架构师，
而 jbpm 是一个非常有名的工作流引擎，当然 activiti 也是一个工作流引擎。</li> <li>Activiti 是一个工作流引擎， activiti 可以将业务系统中复杂的业务流程抽取出来，使用专门的
建模语言（BPMN2.0）进行定义，业务系统按照预先定义的流程进行执行，实现了业务系统的业务
流程由 activiti 进行管理，减少业务系统由于流程变更进行系统升级改造的工作量，从而提高系统的
健壮性，同时也减少了系统开发维护成本。</li></ul> <p>官方网站:  https://www.activiti.org</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210601093528001.png" alt=""></strong></p> <h3 id="_3-2-activiti7内部核心机制"><a href="#_3-2-activiti7内部核心机制" class="header-anchor">#</a> 3.2 Activiti7内部核心机制</h3> <ul><li>1️⃣业务流程图要规范化，需要遵守一套标准。</li> <li>2️⃣业务流程图本质上就是一个XML文件，而XML可以存放所要的数据。</li> <li>3️⃣读取业务流程图的过程就是解析XML文件的过程。</li> <li>4️⃣读取一个业务流程图的结点就相当于解析一个XML的结点，进一步将数据插入到MySQL表中，形成一条记录。</li> <li>5️⃣将一个业务流程图的所有节点都读取并存入到MySQL表中。</li> <li>6️⃣后面只要读取MySQL表中的记录就相当于读取业务流程图的一个节点。</li> <li>7️⃣业务流程的推进，后面就转换为读取表中的数据，并且处理数据，结束的时候这一行数据就可以删除了。</li></ul> <h3 id="_3-3-bpmn"><a href="#_3-3-bpmn" class="header-anchor">#</a> 3.3 BPMN</h3> <ul><li><p>BPMN（Business Process Model And Notation），业务流程模型和符号，是由BPMI（Business Process Management Initiative）开发的一套的业务流程建模符号，使用BPMN提供的符号可以创建业务流程。2004年5月发布了BPMN1.0规范。BPMI于2005年9月并入OMG（The Object Management Group，对象管理组织）组织。OMG于2011年1月发布BPMN2.0的最终版本。</p></li> <li><p>Activit就是使用BPMN2.0进行流程建模、流程执行管理，它包括很多的建模符号。</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210601095019488.png" alt=""></strong></p></li> <li><p>一个BPMN的例子：</p> <ol><li>当事人填写请假单，启动流程后把请假单ID绑定到流程中；</li> <li>部门经理对请假单进行审核；</li> <li>然后人事经理进行复核并进行备案；</li> <li>最后请假流程结束。</li></ol> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210601100705141.png" alt=""></strong></p> <p>思考: 我们看到的是一张图片(png),但是应用程序如何知道下一个节点应该流向到哪里呢?拿到需要去解析png文件吗?</p></li> <li><p>BPMN其实是用XML表示业务流程的，上面的.bpmn文件使用文本编辑器打开：</p> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>definitions</span> <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.omg.org/spec/BPMN/20100524/MODEL<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">xmlns:</span>activiti</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://activiti.org/bpmn<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">xmlns:</span>bpmndi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.omg.org/spec/BPMN/20100524/DI<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">xmlns:</span>omgdc</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.omg.org/spec/DD/20100524/DC<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">xmlns:</span>omgdi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.omg.org/spec/DD/20100524/DI<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">xmlns:</span>tns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.activiti.org/test<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">xmlns:</span>xsd</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span> <span class="token attr-name">expressionLanguage</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/1999/XPath<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>m1620716847764<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span><span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetNamespace</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.activiti.org/test<span class="token punctuation">&quot;</span></span> <span class="token attr-name">typeLanguage</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>process</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>leave<span class="token punctuation">&quot;</span></span> <span class="token attr-name">isClosed</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>false<span class="token punctuation">&quot;</span></span> <span class="token attr-name">isExecutable</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span> <span class="token attr-name">processType</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>None<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>startEvent</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_2<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>StartEvent<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>userTask</span> <span class="token attr-name"><span class="token namespace">activiti:</span>candidateUsers</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>lisi,wangwu<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">activiti:</span>exclusive</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_4<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>部门经理审批<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>userTask</span> <span class="token attr-name"><span class="token namespace">activiti:</span>assignee</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>rose<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">activiti:</span>exclusive</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_6<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>人事复批<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>endEvent</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_7<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>EndEvent<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sequenceFlow</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_12<span class="token punctuation">&quot;</span></span> <span class="token attr-name">sourceRef</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_6<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetRef</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_7<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sequenceFlow</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_13<span class="token punctuation">&quot;</span></span> <span class="token attr-name">sourceRef</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_2<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetRef</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_4<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>sequenceFlow</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_14<span class="token punctuation">&quot;</span></span> <span class="token attr-name">sourceRef</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_4<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetRef</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_6<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>process</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNDiagram</span> <span class="token attr-name">documentation</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>background=#FFFFFF;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>Diagram-_1<span class="token punctuation">&quot;</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>New Diagram<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNPlane</span> <span class="token attr-name">bpmnElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>leave<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNShape</span> <span class="token attr-name">bpmnElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_2<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>Shape-_2<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdc:</span>Bounds</span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>32.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>32.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>175.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>185.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdc:</span>Bounds</span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>32.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>32.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNShape</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNShape</span> <span class="token attr-name">bpmnElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_4<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>Shape-_4<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdc:</span>Bounds</span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>55.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>85.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>245.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>175.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdc:</span>Bounds</span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>55.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>85.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNShape</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNShape</span> <span class="token attr-name">bpmnElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_6<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>Shape-_6<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdc:</span>Bounds</span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>55.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>85.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>380.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>175.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdc:</span>Bounds</span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>55.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>85.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNShape</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNShape</span> <span class="token attr-name">bpmnElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_7<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>Shape-_7<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdc:</span>Bounds</span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>32.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>32.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>505.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>185.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdc:</span>Bounds</span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>32.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>32.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNShape</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNEdge</span> <span class="token attr-name">bpmnElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_13<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>BPMNEdge__13<span class="token punctuation">&quot;</span></span> <span class="token attr-name">sourceElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_2<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_4<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdi:</span>waypoint</span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>207.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>201.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdi:</span>waypoint</span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>245.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>202.5<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdc:</span>Bounds</span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNEdge</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNEdge</span> <span class="token attr-name">bpmnElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_12<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>BPMNEdge__12<span class="token punctuation">&quot;</span></span> <span class="token attr-name">sourceElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_6<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_7<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdi:</span>waypoint</span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>465.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>202.5<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdi:</span>waypoint</span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>505.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>201.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdc:</span>Bounds</span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNEdge</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNEdge</span> <span class="token attr-name">bpmnElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_14<span class="token punctuation">&quot;</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>BPMNEdge__14<span class="token punctuation">&quot;</span></span> <span class="token attr-name">sourceElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_4<span class="token punctuation">&quot;</span></span> <span class="token attr-name">targetElement</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>_6<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdi:</span>waypoint</span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>330.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>202.5<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdi:</span>waypoint</span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>380.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>202.5<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">omgdc:</span>Bounds</span> <span class="token attr-name">height</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">width</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">x</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span> <span class="token attr-name">y</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>0.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNLabel</span><span class="token punctuation">&gt;</span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNEdge</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNPlane</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">bpmndi:</span>BPMNDiagram</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>definitions</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br></div></div></li></ul> <h3 id="_3-4-activiti如何使用"><a href="#_3-4-activiti如何使用" class="header-anchor">#</a> 3.4 Activiti如何使用</h3> <h4 id="_3-4-1-整合activiti"><a href="#_3-4-1-整合activiti" class="header-anchor">#</a> 3.4.1 整合Activiti</h4> <ul><li>Activiti是一个工作流引擎，业务系统使用Activiti来对系统的业务流程进行自动化管理，为了方便业务系统访问（操作）Activiti的接口或功能，通常将Activiti和业务系统的环境集成在一起。</li></ul> <h4 id="_3-4-2-业务流程建模"><a href="#_3-4-2-业务流程建模" class="header-anchor">#</a> 3.4.2 业务流程建模</h4> <ul><li>使用Activiti流程建模工具(Activity-designer)定义业务流程(.bpmn文件)。</li> <li>.bpmn文件就是业务流程定义文件，通过xml定义业务流程。</li> <li>如果使用其他公司开发的工作引擎一般都提供了可视化的建模工具（Process Designer）用于生成流程定义文件，建模工具操作直观，一般都支持图形化拖拽方式、多窗口的用户界面、丰富的过程图形元素、过程元素拷贝、粘贴、删除等功能。</li></ul> <h4 id="_3-4-3-部署业务流程"><a href="#_3-4-3-部署业务流程" class="header-anchor">#</a> 3.4.3 部署业务流程</h4> <ul><li>向Activiti部署业务流程定义(.bpmn文件)。</li> <li>使用Activiti提供的API向Activiti中部署.bpmn文件（一般情况下还需要一起部署业务流程的图片.png）。</li></ul> <h4 id="_3-4-4-启动流程实例"><a href="#_3-4-4-启动流程实例" class="header-anchor">#</a> 3.4.4 启动流程实例</h4> <ul><li>启动一个流程实例表示开始一次业务流程的运行，比如员工请假流程部署完成，如果张三要请假就可以启动一个流程实例，如果李四要请假也需要启动一个流程实例，两个流程的执行互不影响，就好比定义一个Java类，实例化两个Java对象一样，部署的流程就好比Java类，启动一个流程实例就好比new一个Java对象。</li></ul> <h4 id="_3-4-5-查询待办任务"><a href="#_3-4-5-查询待办任务" class="header-anchor">#</a> 3.4.5 查询待办任务</h4> <ul><li>因为现在系统的业务流程已经交给Activiti管理，通过Activiti就可以查询当前流程执行到哪里了，当前用户需要办理什么任务了，这些Activiti帮我们管理了，而不像传统方式中需要我们在SQL语句中的WHERE条件中指定当前查询的状态值是多少。</li></ul> <h4 id="_3-4-6-处理待办任务"><a href="#_3-4-6-处理待办任务" class="header-anchor">#</a> 3.4.6 处理待办任务</h4> <ul><li>用户查询待办任务后，就可以办理某个任务，如果这任务办理完成还需要其他用户办理，比如采购单创建后由部门经理审核，这个过程也是由Activiti帮我们完成了，不需要我们在代码中硬编码指定下一个任务办理人了</li></ul> <h4 id="_3-4-7-结束流程"><a href="#_3-4-7-结束流程" class="header-anchor">#</a> 3.4.7 结束流程</h4> <ul><li>当任务办理完成没有下一个任务/结点了，这个流程实例就完成了。</li></ul> <h2 id="四、activiti7环境"><a href="#四、activiti7环境" class="header-anchor">#</a> 四、Activiti7环境</h2> <h3 id="_4-1-开发环境"><a href="#_4-1-开发环境" class="header-anchor">#</a> 4.1 开发环境</h3> <p>Jdk1.8或以上版本</p> <p>Mysql 5及以上的版本</p> <p>Tomcat8.5</p> <p>IDEA2019---超了建模插件用不了</p> <p>Activiti 7.0.0.SR1</p> <h3 id="_4-2-安装activiti流程设计器"><a href="#_4-2-安装activiti流程设计器" class="header-anchor">#</a> 4.2 安装Activiti流程设计器</h3> <h4 id="_4-2-1-在线安装"><a href="#_4-2-1-在线安装" class="header-anchor">#</a> 4.2.1 在线安装</h4> <p>在<code>Plugins</code>中搜索<code>actiBPM</code>，然后点击<code>Search in repositories</code>,无法在线安装的同学请选择本地安装</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210601110835928.png" alt=""></strong></p> <p>会弹出如下窗口</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210601111038435.png" alt=""></strong></p> <p>安装完成之后，点击<code>Restart IntelliJ IDEA</code> 重启IDEA即可</p> <h4 id="_4-2-2-本地安装"><a href="#_4-2-2-本地安装" class="header-anchor">#</a> 4.2.2 本地安装</h4> <ol><li><p>从IDEA官网下载<code>actiBPM.jar</code>包,下载地址:https://plugins.jetbrains.com/plugin/7429-actibpm/versions</p></li> <li><p>从本地安装actiBPM</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210601111706743.png" alt=""></strong></p> <p>点击<code>Install plugin from disk</code> 后选择下载好的<code>actiBPM.jar</code>，然后重启IDEA即可.</p></li></ol> <h3 id="_4-3-解决actibpm中文乱码"><a href="#_4-3-解决actibpm中文乱码" class="header-anchor">#</a> 4.3 解决actiBPM中文乱码</h3> <ul><li><p>在IDEA中将File--&gt;Settings--&gt;Editor--&gt;File Encodings修改为UTF-8</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210601112410038.png" alt=""></strong></p></li> <li><p>在IDEA的Help--&gt;Edit Custom VM Options中末尾添加<code>-Dfile.encoding=UTF-8</code></p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210601112540972.png" alt=""></strong></p></li> <li><p>在IDEA的安装目录的bin目录下将idea.exe.vmoptions和idea64.exe.vmoptions两个文件末尾添加<code>-Dfile.encoding=UTF-8</code></p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210601112902615.png" alt=""></strong></p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210601112632308.png" alt=""></strong></p></li> <li><p>重启IDEA即可。</p></li></ul> <h3 id="_4-4-activiti支持的数据库"><a href="#_4-4-activiti支持的数据库" class="header-anchor">#</a> 4.4  Activiti支持的数据库</h3> <ul><li><p>Activiti的运行需要数据库的支撑，支持如下:</p> <ul><li>h2</li> <li>MySQL</li> <li>Oracle</li> <li>Db2</li> <li>postgres</li> <li>mssql</li></ul></li> <li><p>在Navicat工具中创建<code>activiti</code>的数据库，用于后续的实验.</p></li></ul> <h2 id="五、集成activiti7"><a href="#五、集成activiti7" class="header-anchor">#</a> 五、集成Activiti7</h2> <h3 id="_5-1-创建maven项目"><a href="#_5-1-创建maven项目" class="header-anchor">#</a> 5.1 创建Maven项目</h3> <ul><li>通过IDEA创建Maven的Java工程。</li></ul> <h3 id="_5-2-添加maven依赖"><a href="#_5-2-添加maven依赖" class="header-anchor">#</a> 5.2 添加Maven依赖</h3> <p>在Java工程中加入ProcessEngine所需要的jar包，包括：</p> <ul><li>activiti-engine-7.0.0.GA.jar</li> <li>activiti依赖的jar包：mybatis、slf4j、log4j等</li> <li>activiti依赖的spring的jar包</li> <li>数据库驱动</li> <li>第三方数据库连接池dbcp</li> <li>单元测试junit</li></ul> <p><code>pom.xml</code>文件</p> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code>    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>properties</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>slf4j.version</span><span class="token punctuation">&gt;</span></span>1.6.6<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>slf4j.version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>log4j.version</span><span class="token punctuation">&gt;</span></span>1.2.12<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>log4j.version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>activiti.version</span><span class="token punctuation">&gt;</span></span>7.0.0.SR1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>activiti.version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>properties</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependencies</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- activiti引擎 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.activiti<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>activiti-engine<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>${activiti.version}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- 整合Spring --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.activiti<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>activiti-spring<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>${activiti.version}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- bpmn 模型处理 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.activiti<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>activiti-bpmn-model<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>${activiti.version}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- bpmn 转换 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.activiti<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>activiti-bpmn-converter<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>${activiti.version}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- bpmn json数据转换 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.activiti<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>activiti-json-converter<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>${activiti.version}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- bpmn 布局 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.activiti<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>activiti-bpmn-layout<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>${activiti.version}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- mysql驱动 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>mysql<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>mysql-connector-java<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>8.0.31<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- mybatis --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.mybatis<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>mybatis<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>3.4.5<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- 链接池 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>commons-dbcp<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>commons-dbcp<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.4<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- 单元测试 --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>junit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>junit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>4.12<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- log start --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>log4j<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>log4j<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>${log4j.version}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.slf4j<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>slf4j-api<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>${slf4j.version}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.slf4j<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>slf4j-log4j12<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>${slf4j.version}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!-- log end --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>commons-io<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>commons-io<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>2.6<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!--数据库连接池--&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.alibaba<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>druid<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.2.4<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependencies</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br><span class="line-number">91</span><br><span class="line-number">92</span><br><span class="line-number">93</span><br><span class="line-number">94</span><br><span class="line-number">95</span><br></div></div><h3 id="_5-3-添加log4j日志配置"><a href="#_5-3-添加log4j日志配置" class="header-anchor">#</a> 5.3 添加log4j日志配置</h3> <p>我们使用log4j日志包，可以对日志进行配置，在<code>resources</code>下创建<code>log4j.properties</code>,内容如下:</p> <div class="language-properties line-numbers-mode"><pre class="language-properties"><code><span class="token comment">## Set root category priority to INFO and its only appender to CONSOLE.</span>
<span class="token comment">#log4j.rootCategory=INFO, CONSOLE debug info warn error fatal</span>
<span class="token key attr-name">log4j.rootCategory</span><span class="token punctuation">=</span><span class="token value attr-value">debug, CONSOLE, LOGFILE</span>
<span class="token comment">## Set the enterprise logger category to FATAL and its only appender to CONSOLE.</span>
<span class="token key attr-name">log4j.logger.org.apache.axis.enterprise</span><span class="token punctuation">=</span><span class="token value attr-value">FATAL, CONSOLE</span>
<span class="token comment">## CONSOLE is set to be a ConsoleAppender using a PatternLayout.</span>
<span class="token key attr-name">log4j.appender.CONSOLE</span><span class="token punctuation">=</span><span class="token value attr-value">org.apache.log4j.ConsoleAppender</span>
<span class="token key attr-name">log4j.appender.CONSOLE.layout</span><span class="token punctuation">=</span><span class="token value attr-value">org.apache.log4j.PatternLayout</span>
<span class="token key attr-name">log4j.appender.CONSOLE.layout.ConversionPattern</span><span class="token punctuation">=</span><span class="token value attr-value">%d{ISO8601} %-6r[%15.15t] %-5p %30.30c %x - %m\n</span>
<span class="token comment">## LOGFILE is set to be a File appender using a PatternLayout.</span>
<span class="token key attr-name">log4j.appender.LOGFILE</span><span class="token punctuation">=</span><span class="token value attr-value">org.apache.log4j.FileAppender</span>
<span class="token key attr-name">log4j.appender.LOGFILE.File</span><span class="token punctuation">=</span><span class="token value attr-value">./activiti.log</span>
<span class="token key attr-name">log4j.appender.LOGFILE.Append</span><span class="token punctuation">=</span><span class="token value attr-value">true</span>
<span class="token key attr-name">log4j.appender.LOGFILE.layout</span><span class="token punctuation">=</span><span class="token value attr-value">org.apache.log4j.PatternLayout</span>
<span class="token key attr-name">log4j.appender.LOGFILE.layout.ConversionPattern</span><span class="token punctuation">=</span><span class="token value attr-value">%d{ISO8601} %-6r[%15.15t] %-5p %30.30c %x - %m\n</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><h3 id="_5-4-添加核心配置文件"><a href="#_5-4-添加核心配置文件" class="header-anchor">#</a> 5.4 添加核心配置文件</h3> <ul><li>需要在<code>resource</code>目录中添加配置文件<code>activiti.cfg.xml</code>,内容如下:</li></ul> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>beans</span> <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.springframework.org/schema/beans<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">xmlns:</span>context</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.springframework.org/schema/context<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">xmlns:</span>tx</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.springframework.org/schema/tx<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">xsi:</span>schemaLocation</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.springframework.org/schema/beans
                    http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/contex
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>beans</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><ul><li>需要在配置文件中配置如下信息
<ul><li>数据库连接池</li> <li>Activiti单独运行的ProcessEngine配置</li></ul></li></ul> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>beans</span> <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.springframework.org/schema/beans<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">xmlns:</span>context</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.springframework.org/schema/context<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">xmlns:</span>tx</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.springframework.org/schema/tx<span class="token punctuation">&quot;</span></span>
       <span class="token attr-name"><span class="token namespace">xsi:</span>schemaLocation</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.springframework.org/schema/beans
                    http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/contex
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>

    <span class="token comment">&lt;!--数据库连接池--&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>dataSource<span class="token punctuation">&quot;</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.alibaba.druid.pool.DruidDataSource<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>driverClassName<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.mysql.cj.jdbc.Driver<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>url<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>jdbc:mysql:///activiti?useSSL=false<span class="token entity named-entity" title="&amp;">&amp;amp;</span>serverTimezone=UTC<span class="token entity named-entity" title="&amp;">&amp;amp;</span>nullCatalogMeansCurrent=true<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>username<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>root<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>password<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>admin<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>
    <span class="token comment">&lt;!-- 默认id对应的值 为processEngineConfiguration --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>processEngineConfiguration<span class="token punctuation">&quot;</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>dataSource<span class="token punctuation">&quot;</span></span> <span class="token attr-name">ref</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>dataSource<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
        <span class="token comment">&lt;!--
            activiti数据库表处理策略
                false(默认值)：检查数据库的版本和依赖库的版本，如果不匹配就抛出异常
                true：构建流程引擎时，执行检查，如果需要就执行更新。如果表不存在，就创建。
                create-drop：构建流程引擎时创建数据库报表，关闭流程引擎时就删除这些表。
                drop-create：先删除表再创建表。
                create：构建流程引擎时创建数据库表，关闭流程引擎时不删除这些表
        --&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>databaseSchemaUpdate<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>true<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>


<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>beans</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br></div></div><h3 id="_5-5-测试"><a href="#_5-5-测试" class="header-anchor">#</a> 5.5 测试</h3> <ul><li>创建一个测试类，调用activiti的工具类，生成acitivti需要的数据库表。代码如下:</li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">cn<span class="token punctuation">.</span>wolfcode<span class="token punctuation">.</span>demo</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token class-name">ProcessEngine</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token class-name">ProcessEngines</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>junit<span class="token punctuation">.</span></span><span class="token class-name">Test</span></span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">class</span> _01TestInit <span class="token punctuation">{</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testInit</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>processEngine<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div><h3 id="_5-6-数据库表的命名规则"><a href="#_5-6-数据库表的命名规则" class="header-anchor">#</a> 5.6 数据库表的命名规则</h3> <ul><li><p>此时我们查看数据库，发现25张表，结果如下所示：</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210601160540721.png" alt=""></strong></p></li></ul> <p>Activiti的表都是以<code>ACT_</code>开头。第二部分是表示表的用途的两个字母标识。用途也和服务的API对应。</p> <ul><li><code>ACT_RE_*</code>：'RE'表示Repository。这个前缀的表包含了流程定义和流程静态资源（图片、规则等等）。</li> <li><code>ACT_RU_*</code>：'RU'表示Runtime。这些运行时的表，包含流程实例，任务、变量，异步任务等运行中的数据。Activiti只在流程实例执行过程中保存这些数据，在流程结束时就会删除这些记录。这些运行时表可以一直很小并且速度很快。</li> <li><code>ACT_HI_*</code>：'HI'表示History。这些表包含历史数据，比如历史流程实例，变量，任务等等。</li> <li><code>ACT_GE_*</code>：'GE'表示General。通用数据，用于不同场景下。</li></ul> <h2 id="六、流程引擎api"><a href="#六、流程引擎api" class="header-anchor">#</a> 六、流程引擎API</h2> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210601163508919.png" alt=""></strong></p> <p><code>ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();</code></p> <p>这行代码默认是读取<code>resource</code>目录下的<code>activiti.cfg.xml</code>文件，这个文件本质上就是spring的配置文件，加载之后会读取配置文件中id名为<code>processEngineConfiguration</code>的bean,通过这个配置对象可以获取到流程引擎对象<code>ProcessEngine</code></p> <p><strong>Service总览</strong></p> <table><thead><tr><th>Service接口</th> <th>说明</th></tr></thead> <tbody><tr><td>RepositoryService</td> <td>Activiti的资源管理接口</td></tr> <tr><td>RuntimeService</td> <td>Activiti的流程运行管理接口</td></tr> <tr><td>TaskService</td> <td>Activiti的任务管理接口</td></tr> <tr><td>HistoryService</td> <td>Activiti的历史管理接口</td></tr> <tr><td>ManagementService</td> <td>Activiti的引擎管理接口</td></tr></tbody></table> <ul><li><p><strong>RepositoryService</strong>，是Activiti的资源管理接口，提供了管理和控制流程发布包和流程定义的操作。使用工作流建模工具设计的业务流程图需要使用此Service将流程定义文件的内容部署到计算机中。</p></li> <li><p><strong>RuntimeService</strong>，是Activiti的流程运行管理接口，可以从这个接口中获取很多关于流程执行相关的信息。</p></li> <li><p><strong>TaskService</strong>，是Activiti的任务管理接口，可以从这个接口中获取任务的信息。</p></li> <li><p><strong>HistoryService</strong>，是Activiti的历史管理类，可以查询历史信息，执行流程时，引擎会包含很多数据（根据配置），比如流程实例启动时间，任务的参与者，完成任务的时间，每个流程实例的执行路径，等等。</p></li> <li><p><strong>ManagementService</strong>，是Activiti的引擎管理接口，提供了对Activiti流程引擎的管理和维护功能，这些功能不在工作流驱动的应用程序中使用，主要用于Activiti系统的日常维护。</p></li></ul> <h2 id="七、activiti7入门"><a href="#七、activiti7入门" class="header-anchor">#</a> 七、Activiti7入门</h2> <h3 id="_7-1-业务流程建模"><a href="#_7-1-业务流程建模" class="header-anchor">#</a> 7.1 业务流程建模</h3> <h4 id="_7-1-1-绘制流程图"><a href="#_7-1-1-绘制流程图" class="header-anchor">#</a> 7.1.1 绘制流程图</h4> <p>在<code>resource</code>目录下新建<code>bpmn</code>目录用于存放所有的流程文件 ,在<code>bpmn</code>目录下新建<code>leave.bpmn</code>,内容如下:</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210602170615549.png" alt=""></strong></p> <h4 id="_7-1-2-指定任务负责人"><a href="#_7-1-2-指定任务负责人" class="header-anchor">#</a> 7.1.2 指定任务负责人</h4> <ul><li>为每个任务结点指定负责人，如部门经理的审核人是李四。</li></ul> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210602170718364.png" alt=""></strong></p> <h4 id="_7-1-3-生成png格式流程图"><a href="#_7-1-3-生成png格式流程图" class="header-anchor">#</a> 7.1.3 生成png格式流程图</h4> <p><code>bpmn</code>文件本质上是xml格式,我们打开看到的是图片格式是因为我们在IDEA中安装了actiBPM的插件.</p> <p>如果我们把<code>bpmn</code>文件部署到Web环境,那么就只能看到xml信息,无法看到类似上面的图形了.</p> <p>我们可以再部署之前，根据<code>bpmn</code>文件生成<code>png</code>文件，然后把<code>bpmn</code>和<code>png</code>文件同时部署到Web环境中.如果我们想查看流程图的话，我们就可以通过Activiti把这个<code>png</code>文件读取出来. 接下来我们把<code>bpmn</code>导出为<code>png</code>文件</p> <ul><li><p>将<code>leave.bpmn</code>文件重命名为<code>leave.xml</code>文件</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210602093612229.png" alt=""></strong></p></li> <li><p>右键点击<code>leave.xml</code>文件 --&gt; <code>Diagrams</code> --&gt;  <code>Show BPMN Designer...</code></p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210602093758100.png" alt=""></strong></p></li> <li><p>点击导出按钮,保存在<code>resource/bpmn</code>同级目录下</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210602170832647.png" alt=""></strong></p></li> <li><p>导出<code>png</code>之后,把<code>leave.xml</code>更名为<code>leave.bpmn</code></p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210602094800547.png" alt=""></strong></p></li></ul> <h3 id="_7-2-部署流程定义"><a href="#_7-2-部署流程定义" class="header-anchor">#</a> 7.2 部署流程定义</h3> <ul><li>使用RepositoryService部署流程定义</li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">cn<span class="token punctuation">.</span>wolfcode<span class="token punctuation">.</span>demo</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token class-name">ProcessEngine</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token class-name">ProcessEngines</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token class-name">RepositoryService</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>repository<span class="token punctuation">.</span></span><span class="token class-name">Deployment</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>junit<span class="token punctuation">.</span></span><span class="token class-name">Test</span></span><span class="token punctuation">;</span>

<span class="token comment">/**
 * Created by wolfcode
 */</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">ActivitiTest</span> <span class="token punctuation">{</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testDeploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取RepositoryService对象</span>
        <span class="token class-name">RepositoryService</span> repositoryService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRepositoryService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//进行部署</span>
        <span class="token class-name">Deployment</span> deployment <span class="token operator">=</span> repositoryService<span class="token punctuation">.</span><span class="token function">createDeployment</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">addClasspathResource</span><span class="token punctuation">(</span><span class="token string">&quot;bpmn/leave.bpmn&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">addClasspathResource</span><span class="token punctuation">(</span><span class="token string">&quot;bpmn/leave.png&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token string">&quot;请假流程&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">deploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//输出部署的一些信息</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署ID:&quot;</span><span class="token operator">+</span>deployment<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署名称:&quot;</span><span class="token operator">+</span>deployment<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>z
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br></div></div><p>观察日志发现，进行部署会操作如下表.</p> <ul><li>ACT_GE_PROPERTY 引擎属性表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">update</span> ACT_GE_PROPERTY <span class="token keyword">SET</span> REV_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> VALUE_ <span class="token operator">=</span> ? <span class="token keyword">where</span> NAME_ <span class="token operator">=</span> ? <span class="token operator">and</span> REV_ <span class="token operator">=</span> ? 

Parameters: <span class="token number">2</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">next</span><span class="token punctuation">.</span>dbid<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_RE_PROCDEF 流程定义表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_RE_PROCDEF<span class="token punctuation">(</span>ID_<span class="token punctuation">,</span> REV_<span class="token punctuation">,</span> CATEGORY_<span class="token punctuation">,</span> NAME_<span class="token punctuation">,</span> KEY_<span class="token punctuation">,</span> VERSION_<span class="token punctuation">,</span> DEPLOYMENT_ID_<span class="token punctuation">,</span> RESOURCE_NAME_<span class="token punctuation">,</span> DGRM_RESOURCE_NAME_<span class="token punctuation">,</span> DESCRIPTION_<span class="token punctuation">,</span> HAS_START_FORM_KEY_<span class="token punctuation">,</span> HAS_GRAPHICAL_NOTATION_ <span class="token punctuation">,</span> SUSPENSION_STATE_<span class="token punctuation">,</span> TENANT_ID_<span class="token punctuation">,</span> ENGINE_VERSION_<span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> 

Parameters: leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> http:<span class="token comment">//www.activiti.org/test(String), 请假流程(String), leaveProcess(String), 1(Integer), 1(String), bpmn/leave.bpmn(String), bpmn/leave.png(String), null, false(Boolean), true(Boolean), 1(Integer), (String), null</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_RE_DEPLOYMENT 流程部署表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_RE_DEPLOYMENT<span class="token punctuation">(</span>ID_<span class="token punctuation">,</span> NAME_<span class="token punctuation">,</span> CATEGORY_<span class="token punctuation">,</span> KEY_<span class="token punctuation">,</span> TENANT_ID_<span class="token punctuation">,</span> DEPLOY_TIME_<span class="token punctuation">,</span> ENGINE_VERSION_<span class="token punctuation">)</span> <span class="token keyword">values</span><span class="token punctuation">(</span>?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> 

Parameters: <span class="token number">1</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 请假流程<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">11</span>:<span class="token number">01</span>:<span class="token number">44.838</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_GE_BYTEARRAY 二进制资源表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> ACT_GE_BYTEARRAY<span class="token punctuation">(</span>ID_<span class="token punctuation">,</span> REV_<span class="token punctuation">,</span> NAME_<span class="token punctuation">,</span> BYTES_<span class="token punctuation">,</span> DEPLOYMENT_ID_<span class="token punctuation">,</span> GENERATED_<span class="token punctuation">)</span> <span class="token keyword">VALUES</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> <span class="token punctuation">,</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> 

Parameters: <span class="token number">2</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> bpmn<span class="token operator">/</span><span class="token keyword">leave</span><span class="token punctuation">.</span>png<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> java<span class="token punctuation">.</span>io<span class="token punctuation">.</span>ByteArrayInputStream<span class="token variable">@7fe7c640</span><span class="token punctuation">(</span>ByteArrayInputStream<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> bpmn<span class="token operator">/</span><span class="token keyword">leave</span><span class="token punctuation">.</span>bpmn<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> java<span class="token punctuation">.</span>io<span class="token punctuation">.</span>ByteArrayInputStream<span class="token variable">@4c4748bf</span><span class="token punctuation">(</span>ByteArrayInputStream<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="_7-3-启动流程实例"><a href="#_7-3-启动流程实例" class="header-anchor">#</a> 7.3 启动流程实例</h3> <ul><li>流程定义部署在Activiti中之后就可以通过工作流管理业务流程了。</li> <li>针对该流程，启动一个流程表示发起一个新的请假申请单，这就相当于Java类和Java对象的关系，类定义好之后需要new创建一个对象使用，当然，也可以new多个对象。</li> <li>对于请假申请流程，张三发起一个请假申请单需要启动一个流程实例，李四发起一个请求申请单也需要启动一个流程实例。</li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testStartProcess</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
	<span class="token comment">//创建ProcessEngine对象</span>
	<span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token comment">//获取RuntimeService对象</span>
	<span class="token class-name">RuntimeService</span> runtimeService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRuntimeService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token comment">//根据流程定义的key启动流程实例,这个key是在定义bpmn的时候设置的</span>
	<span class="token class-name">ProcessInstance</span> instance <span class="token operator">=</span> runtimeService<span class="token punctuation">.</span>
								<span class="token function">startProcessInstanceByKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveProcess&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token comment">//获取流程实例的相关信息</span>
	<span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div><p>观察日志发现，启动流程会操作如下表.</p> <ul><li>ACT_HI_TASKINST 历史任务表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_HI_TASKINST <span class="token punctuation">(</span> ID_<span class="token punctuation">,</span> PROC_DEF_ID_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">,</span> EXECUTION_ID_<span class="token punctuation">,</span> NAME_<span class="token punctuation">,</span> PARENT_TASK_ID_<span class="token punctuation">,</span> DESCRIPTION_<span class="token punctuation">,</span> OWNER_<span class="token punctuation">,</span> ASSIGNEE_<span class="token punctuation">,</span> START_TIME_<span class="token punctuation">,</span> CLAIM_TIME_<span class="token punctuation">,</span> END_TIME_<span class="token punctuation">,</span> DURATION_<span class="token punctuation">,</span> DELETE_REASON_<span class="token punctuation">,</span> TASK_DEF_KEY_<span class="token punctuation">,</span> FORM_KEY_<span class="token punctuation">,</span> PRIORITY_<span class="token punctuation">,</span> DUE_DATE_<span class="token punctuation">,</span> CATEGORY_<span class="token punctuation">,</span> TENANT_ID_ <span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ? <span class="token punctuation">)</span> 

Parameters: <span class="token number">2505</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2502</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 部门经理审批<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> 李四<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">34</span>:<span class="token number">52.827</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> _4<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>String<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_HI_PROCINST 历史流程实例表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_HI_PROCINST <span class="token punctuation">(</span> ID_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">,</span> BUSINESS_KEY_<span class="token punctuation">,</span> PROC_DEF_ID_<span class="token punctuation">,</span> START_TIME_<span class="token punctuation">,</span> END_TIME_<span class="token punctuation">,</span> DURATION_<span class="token punctuation">,</span> START_USER_ID_<span class="token punctuation">,</span> START_ACT_ID_<span class="token punctuation">,</span> END_ACT_ID_<span class="token punctuation">,</span> SUPER_PROCESS_INSTANCE_ID_<span class="token punctuation">,</span> DELETE_REASON_<span class="token punctuation">,</span> TENANT_ID_<span class="token punctuation">,</span> NAME_ <span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ? <span class="token punctuation">)</span> 

Parameters: <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">34</span>:<span class="token number">52.798</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> _2<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_HI_ACTINST 历史活动信息表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_HI_ACTINST <span class="token punctuation">(</span> ID_<span class="token punctuation">,</span> PROC_DEF_ID_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">,</span> EXECUTION_ID_<span class="token punctuation">,</span> ACT_ID_<span class="token punctuation">,</span> TASK_ID_<span class="token punctuation">,</span> CALL_PROC_INST_ID_<span class="token punctuation">,</span> ACT_NAME_<span class="token punctuation">,</span> ACT_TYPE_<span class="token punctuation">,</span> ASSIGNEE_<span class="token punctuation">,</span> START_TIME_<span class="token punctuation">,</span> END_TIME_<span class="token punctuation">,</span> DURATION_<span class="token punctuation">,</span> DELETE_REASON_<span class="token punctuation">,</span> TENANT_ID_ <span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> <span class="token punctuation">,</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> 

Parameters: <span class="token number">2503</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2502</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> _2<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> StartEvent<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> startEvent<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">34</span>:<span class="token number">52.815</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">34</span>:<span class="token number">52.816</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">(</span>Long<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2504</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2502</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> _4<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2505</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> 部门经理审批<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> userTask<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 李四<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">34</span>:<span class="token number">52.817</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>String<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_HI_IDENTITYLINK 历史身份连接表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_HI_IDENTITYLINK <span class="token punctuation">(</span>ID_<span class="token punctuation">,</span> TYPE_<span class="token punctuation">,</span> USER_ID_<span class="token punctuation">,</span> GROUP_ID_<span class="token punctuation">,</span> TASK_ID_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> 

Parameters: <span class="token number">2506</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> participant<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 李四<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_RU_EXECUTION 运行时执行实例表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code><span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_RU_EXECUTION <span class="token punctuation">(</span>ID_<span class="token punctuation">,</span> REV_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">,</span> BUSINESS_KEY_<span class="token punctuation">,</span> PROC_DEF_ID_<span class="token punctuation">,</span> ACT_ID_<span class="token punctuation">,</span> IS_ACTIVE_<span class="token punctuation">,</span> IS_CONCURRENT_<span class="token punctuation">,</span> IS_SCOPE_<span class="token punctuation">,</span>IS_EVENT_SCOPE_<span class="token punctuation">,</span> IS_MI_ROOT_<span class="token punctuation">,</span> PARENT_ID_<span class="token punctuation">,</span> SUPER_EXEC_<span class="token punctuation">,</span> ROOT_PROC_INST_ID_<span class="token punctuation">,</span> SUSPENSION_STATE_<span class="token punctuation">,</span> TENANT_ID_<span class="token punctuation">,</span> NAME_<span class="token punctuation">,</span> START_TIME_<span class="token punctuation">,</span> START_USER_ID_<span class="token punctuation">,</span> IS_COUNT_ENABLED_<span class="token punctuation">,</span> EVT_SUBSCR_COUNT_<span class="token punctuation">,</span> TASK_COUNT_<span class="token punctuation">,</span> JOB_COUNT_<span class="token punctuation">,</span> TIMER_JOB_COUNT_<span class="token punctuation">,</span> SUSP_JOB_COUNT_<span class="token punctuation">,</span> DEADLETTER_JOB_COUNT_<span class="token punctuation">,</span> VAR_COUNT_<span class="token punctuation">,</span> ID_LINK_COUNT_<span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> <span class="token punctuation">,</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> 

Parameters: <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">34</span>:<span class="token number">52.798</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2502</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> _4<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">34</span>:<span class="token number">52.813</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_RU_TASK 运行时任务表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_RU_TASK <span class="token punctuation">(</span>ID_<span class="token punctuation">,</span> REV_<span class="token punctuation">,</span> NAME_<span class="token punctuation">,</span> PARENT_TASK_ID_<span class="token punctuation">,</span> DESCRIPTION_<span class="token punctuation">,</span> PRIORITY_<span class="token punctuation">,</span> CREATE_TIME_<span class="token punctuation">,</span> OWNER_<span class="token punctuation">,</span> ASSIGNEE_<span class="token punctuation">,</span> DELEGATION_<span class="token punctuation">,</span> EXECUTION_ID_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">,</span> PROC_DEF_ID_<span class="token punctuation">,</span> TASK_DEF_KEY_<span class="token punctuation">,</span> DUE_DATE_<span class="token punctuation">,</span> CATEGORY_<span class="token punctuation">,</span> SUSPENSION_STATE_<span class="token punctuation">,</span> TENANT_ID_<span class="token punctuation">,</span> FORM_KEY_<span class="token punctuation">,</span> CLAIM_TIME_<span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ? <span class="token punctuation">)</span> 

Parameters: <span class="token number">2505</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 部门经理审批<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">34</span>:<span class="token number">52.817</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> 李四<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2502</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> _4<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_RU_IDENTITYLINK 运行时身份连接表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_RU_IDENTITYLINK <span class="token punctuation">(</span>ID_<span class="token punctuation">,</span> REV_<span class="token punctuation">,</span> TYPE_<span class="token punctuation">,</span> USER_ID_<span class="token punctuation">,</span> GROUP_ID_<span class="token punctuation">,</span> TASK_ID_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">,</span> PROC_DEF_ID_<span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> 

Parameters: <span class="token number">2506</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> participant<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 李四<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="_7-4-任务查询"><a href="#_7-4-任务查询" class="header-anchor">#</a> 7.4 任务查询</h3> <ul><li>流程启动后，各个任务的负责人就可以查询自己当前需要处理的任务，查询出来的任务都是该用户的待办任务。</li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testSelectTodoTaskList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//任务负责人</span>
    <span class="token class-name">String</span> assignee <span class="token operator">=</span> <span class="token string">&quot;李四&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取TaskService</span>
    <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取任务集合</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Task</span><span class="token punctuation">&gt;</span></span> taskList <span class="token operator">=</span> taskService<span class="token punctuation">.</span><span class="token function">createTaskQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveProcess&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span>assignee<span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//遍历任务列表</span>
    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token operator">:</span>taskList<span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getProcessInstanceId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务名称 = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br></div></div><p>观察日志发现，查询任务会操作如下表.</p> <ul><li>ACT_RU_TASK 运行时任务表</li> <li>ACT_RE_PROCDEF 流程定义表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">select</span> <span class="token keyword">distinct</span> RES<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">from</span> ACT_RU_TASK RES <span class="token keyword">inner</span> <span class="token keyword">join</span> ACT_RE_PROCDEF D <span class="token keyword">on</span> RES<span class="token punctuation">.</span>PROC_DEF_ID_ <span class="token operator">=</span> D<span class="token punctuation">.</span>ID_ <span class="token keyword">WHERE</span> RES<span class="token punctuation">.</span>ASSIGNEE_ <span class="token operator">=</span> ? <span class="token operator">and</span> D<span class="token punctuation">.</span>KEY_ <span class="token operator">=</span> ? <span class="token keyword">order</span> <span class="token keyword">by</span> RES<span class="token punctuation">.</span>ID_ <span class="token keyword">asc</span> <span class="token keyword">LIMIT</span> ? <span class="token keyword">OFFSET</span> ? 

Parameters: 李四<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> leaveProcess<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2147483647</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="_7-5-任务处理"><a href="#_7-5-任务处理" class="header-anchor">#</a> 7.5 任务处理</h3> <ul><li>任务负责人查询待办任务，选择任务进行处理，完成任务。</li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testCompleteTask</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//任务负责人</span>
    <span class="token class-name">String</span> assignee <span class="token operator">=</span> <span class="token string">&quot;李四&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取TaskService</span>
    <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取任务集合</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Task</span><span class="token punctuation">&gt;</span></span> taskList <span class="token operator">=</span> taskService<span class="token punctuation">.</span><span class="token function">createTaskQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveProcess&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span>assignee<span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//遍历任务列表</span>
    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token operator">:</span>taskList<span class="token punctuation">)</span><span class="token punctuation">{</span>
        taskService<span class="token punctuation">.</span><span class="token function">complete</span><span class="token punctuation">(</span>task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><p>观察日志发现，查询任务会操作如下表.</p> <ul><li>ACT_GE_PROPERTY 引擎属性表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">update</span> ACT_GE_PROPERTY <span class="token keyword">SET</span> REV_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> VALUE_ <span class="token operator">=</span> ? <span class="token keyword">where</span> NAME_ <span class="token operator">=</span> ? <span class="token operator">and</span> REV_ <span class="token operator">=</span> ? 

Parameters: <span class="token number">4</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">7501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">next</span><span class="token punctuation">.</span>dbid<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_HI_TASKINST 历史任务表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_HI_TASKINST <span class="token punctuation">(</span> ID_<span class="token punctuation">,</span> PROC_DEF_ID_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">,</span> EXECUTION_ID_<span class="token punctuation">,</span> NAME_<span class="token punctuation">,</span> PARENT_TASK_ID_<span class="token punctuation">,</span> DESCRIPTION_<span class="token punctuation">,</span> OWNER_<span class="token punctuation">,</span> ASSIGNEE_<span class="token punctuation">,</span> START_TIME_<span class="token punctuation">,</span> CLAIM_TIME_<span class="token punctuation">,</span> END_TIME_<span class="token punctuation">,</span> DURATION_<span class="token punctuation">,</span> DELETE_REASON_<span class="token punctuation">,</span> TASK_DEF_KEY_<span class="token punctuation">,</span> FORM_KEY_<span class="token punctuation">,</span> PRIORITY_<span class="token punctuation">,</span> DUE_DATE_<span class="token punctuation">,</span> CATEGORY_<span class="token punctuation">,</span> TENANT_ID_ <span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ? <span class="token punctuation">)</span> 

Parameters: <span class="token number">5002</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2502</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 人事复批<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> 王五<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">39</span>:<span class="token number">19.036</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> _5<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>String<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_HI_ACTINST 历史活动信息表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_HI_ACTINST <span class="token punctuation">(</span> ID_<span class="token punctuation">,</span> PROC_DEF_ID_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">,</span> EXECUTION_ID_<span class="token punctuation">,</span> ACT_ID_<span class="token punctuation">,</span> TASK_ID_<span class="token punctuation">,</span> CALL_PROC_INST_ID_<span class="token punctuation">,</span> ACT_NAME_<span class="token punctuation">,</span> ACT_TYPE_<span class="token punctuation">,</span> ASSIGNEE_<span class="token punctuation">,</span> START_TIME_<span class="token punctuation">,</span> END_TIME_<span class="token punctuation">,</span> DURATION_<span class="token punctuation">,</span> DELETE_REASON_<span class="token punctuation">,</span> TENANT_ID_ <span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ? <span class="token punctuation">)</span> 

Parameters: <span class="token number">5001</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2502</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> _5<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">5002</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> 人事复批<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> userTask<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 王五<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">39</span>:<span class="token number">19.025</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>String<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_HI_IDENTITYLINK 历史身份连接表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_HI_IDENTITYLINK <span class="token punctuation">(</span>ID_<span class="token punctuation">,</span> TYPE_<span class="token punctuation">,</span> USER_ID_<span class="token punctuation">,</span> GROUP_ID_<span class="token punctuation">,</span> TASK_ID_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> 

Parameters: <span class="token number">5003</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> participant<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 王五<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_RU_TASK 运行时任务表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_RU_TASK <span class="token punctuation">(</span>ID_<span class="token punctuation">,</span> REV_<span class="token punctuation">,</span> NAME_<span class="token punctuation">,</span> PARENT_TASK_ID_<span class="token punctuation">,</span> DESCRIPTION_<span class="token punctuation">,</span> PRIORITY_<span class="token punctuation">,</span> CREATE_TIME_<span class="token punctuation">,</span> OWNER_<span class="token punctuation">,</span> ASSIGNEE_<span class="token punctuation">,</span> DELEGATION_<span class="token punctuation">,</span> EXECUTION_ID_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">,</span> PROC_DEF_ID_<span class="token punctuation">,</span> TASK_DEF_KEY_<span class="token punctuation">,</span> DUE_DATE_<span class="token punctuation">,</span> CATEGORY_<span class="token punctuation">,</span> SUSPENSION_STATE_<span class="token punctuation">,</span> TENANT_ID_<span class="token punctuation">,</span> FORM_KEY_<span class="token punctuation">,</span> CLAIM_TIME_<span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ? <span class="token punctuation">)</span> 

Parameters: <span class="token number">5002</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 人事复批<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">39</span>:<span class="token number">19.025</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> 王五<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2502</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> _5<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_RU_IDENTITYLINK 运行时身份连接表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_RU_IDENTITYLINK <span class="token punctuation">(</span>ID_<span class="token punctuation">,</span> REV_<span class="token punctuation">,</span> TYPE_<span class="token punctuation">,</span> USER_ID_<span class="token punctuation">,</span> GROUP_ID_<span class="token punctuation">,</span> TASK_ID_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">,</span> PROC_DEF_ID_<span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> 

Parameters: <span class="token number">5003</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> participant<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 王五<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_RU_EXECUTION 运行时执行实例表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">update</span> ACT_RU_EXECUTION <span class="token keyword">set</span> REV_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> BUSINESS_KEY_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> PROC_DEF_ID_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> ACT_ID_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> IS_ACTIVE_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> IS_CONCURRENT_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> IS_SCOPE_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> IS_EVENT_SCOPE_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> IS_MI_ROOT_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> PARENT_ID_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> SUPER_EXEC_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> ROOT_PROC_INST_ID_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> SUSPENSION_STATE_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> NAME_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> IS_COUNT_ENABLED_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> EVT_SUBSCR_COUNT_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> TASK_COUNT_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> JOB_COUNT_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> TIMER_JOB_COUNT_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> SUSP_JOB_COUNT_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> DEADLETTER_JOB_COUNT_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> VAR_COUNT_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> ID_LINK_COUNT_ <span class="token operator">=</span> ? <span class="token keyword">where</span> ID_ <span class="token operator">=</span> ? <span class="token operator">and</span> REV_ <span class="token operator">=</span> ? 

Parameters: <span class="token number">2</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> _5<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">(</span><span class="token keyword">Boolean</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2502</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_HI_TASKINST 历史任务表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">update</span> ACT_HI_TASKINST <span class="token keyword">set</span> PROC_DEF_ID_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> EXECUTION_ID_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> NAME_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> PARENT_TASK_ID_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> DESCRIPTION_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> OWNER_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> ASSIGNEE_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> CLAIM_TIME_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> END_TIME_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> DURATION_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> DELETE_REASON_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> TASK_DEF_KEY_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> FORM_KEY_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> PRIORITY_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> DUE_DATE_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> CATEGORY_ <span class="token operator">=</span> ? <span class="token keyword">where</span> ID_ <span class="token operator">=</span> ? 

Parameters: leaveProcess:<span class="token number">1</span>:<span class="token number">4</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2502</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 部门经理审批<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> 李四<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">39</span>:<span class="token number">18.995</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">266168</span><span class="token punctuation">(</span>Long<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> _4<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">50</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2505</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_HI_TASKINST 历史任务表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">update</span> ACT_HI_ACTINST <span class="token keyword">set</span> EXECUTION_ID_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> ASSIGNEE_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> END_TIME_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> DURATION_ <span class="token operator">=</span> ?<span class="token punctuation">,</span> DELETE_REASON_ <span class="token operator">=</span> ? <span class="token keyword">where</span> ID_ <span class="token operator">=</span> ? 

Parameters: <span class="token number">2502</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 李四<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">39</span>:<span class="token number">19.009</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">266192</span><span class="token punctuation">(</span>Long<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">2504</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>ACT_RU_TASK 运行时任务表</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">delete</span> <span class="token keyword">from</span> ACT_RU_TASK <span class="token keyword">where</span> ID_ <span class="token operator">=</span> ? <span class="token operator">and</span> REV_ <span class="token operator">=</span> ? 

Parameters: <span class="token number">2505</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">(</span><span class="token keyword">Integer</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="_7-6-添加审批意见"><a href="#_7-6-添加审批意见" class="header-anchor">#</a> 7.6 添加审批意见</h3> <ul><li>在执行任务之前可以给该任务添加审批意见,会存储在历史表中,我们后续可以审批历史中查看到该意见</li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testAddComment</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//任务负责人</span>
    <span class="token class-name">String</span> assignee <span class="token operator">=</span> <span class="token string">&quot;王五&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取TaskService</span>
    <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取任务集合</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Task</span><span class="token punctuation">&gt;</span></span> taskList <span class="token operator">=</span> taskService<span class="token punctuation">.</span><span class="token function">createTaskQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveProcess&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span>assignee<span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//遍历任务列表</span>
    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token operator">:</span>taskList<span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//在任务执行之前任务添加批注信息</span>
        taskService<span class="token punctuation">.</span><span class="token function">addComment</span><span class="token punctuation">(</span>task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>task<span class="token punctuation">.</span><span class="token function">getProcessInstanceId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>task<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">+</span><span class="token string">&quot;审批通过&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        taskService<span class="token punctuation">.</span><span class="token function">complete</span><span class="token punctuation">(</span>task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br></div></div><p>观察日志发现，其余操作和任务处理的表是一致的，但是添加批注会往如下表中插入记录:</p> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code>Preparing: <span class="token keyword">insert</span> <span class="token keyword">into</span> ACT_HI_COMMENT <span class="token punctuation">(</span>ID_<span class="token punctuation">,</span> TYPE_<span class="token punctuation">,</span> TIME_<span class="token punctuation">,</span> USER_ID_<span class="token punctuation">,</span> TASK_ID_<span class="token punctuation">,</span> PROC_INST_ID_<span class="token punctuation">,</span> ACTION_<span class="token punctuation">,</span> MESSAGE_<span class="token punctuation">,</span> FULL_MSG_<span class="token punctuation">)</span> <span class="token keyword">values</span> <span class="token punctuation">(</span>?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">,</span> ?<span class="token punctuation">)</span> 

Parameters: <span class="token number">7501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">comment</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2021</span><span class="token operator">-</span><span class="token number">06</span><span class="token operator">-</span><span class="token number">02</span> <span class="token number">16</span>:<span class="token number">43</span>:<span class="token number">09.13</span><span class="token punctuation">(</span><span class="token keyword">Timestamp</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">null</span><span class="token punctuation">,</span> <span class="token number">5002</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">2501</span><span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> AddComment<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> 人事复批审批通过<span class="token punctuation">(</span>String<span class="token punctuation">)</span><span class="token punctuation">,</span> java<span class="token punctuation">.</span>io<span class="token punctuation">.</span>ByteArrayInputStream<span class="token variable">@1b765a2c</span><span class="token punctuation">(</span>ByteArrayInputStream<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="_7-6-查看历史审批"><a href="#_7-6-查看历史审批" class="header-anchor">#</a> 7.6 查看历史审批</h3> <ul><li>用户可以查看历史审批记录</li></ul> <div class="language-JAVA line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testSelectHistoryTask</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//流程实例ID</span>
    <span class="token class-name">String</span> processInstanceId <span class="token operator">=</span> <span class="token string">&quot;2501&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//任务审核人</span>
    <span class="token class-name">String</span> taskAssignee <span class="token operator">=</span> <span class="token string">&quot;王五&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取historyService</span>
    <span class="token class-name">HistoryService</span> historyService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getHistoryService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取taskService</span>
    <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取历史审核信息</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">HistoricActivityInstance</span><span class="token punctuation">&gt;</span></span> list <span class="token operator">=</span> historyService
            <span class="token punctuation">.</span><span class="token function">createHistoricActivityInstanceQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">activityType</span><span class="token punctuation">(</span><span class="token string">&quot;userTask&quot;</span><span class="token punctuation">)</span><span class="token comment">//只获取用户任务</span>
            <span class="token punctuation">.</span><span class="token function">processInstanceId</span><span class="token punctuation">(</span>processInstanceId<span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span>taskAssignee<span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">finished</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">HistoricActivityInstance</span> instance<span class="token operator">:</span>list<span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务名称:&quot;</span><span class="token operator">+</span>instance<span class="token punctuation">.</span><span class="token function">getActivityName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务开始时间:&quot;</span><span class="token operator">+</span>instance<span class="token punctuation">.</span><span class="token function">getStartTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务结束时间:&quot;</span><span class="token operator">+</span>instance<span class="token punctuation">.</span><span class="token function">getEndTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务耗时:&quot;</span><span class="token operator">+</span>instance<span class="token punctuation">.</span><span class="token function">getDurationInMillis</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取审核批注信息</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Comment</span><span class="token punctuation">&gt;</span></span> taskComments <span class="token operator">=</span> taskService<span class="token punctuation">.</span><span class="token function">getTaskComments</span><span class="token punctuation">(</span>instance<span class="token punctuation">.</span><span class="token function">getTaskId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>taskComments<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">&gt;</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
            <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;审批批注:&quot;</span><span class="token operator">+</span>taskComments<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getFullMessage</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br></div></div><h2 id="八、activiti7进阶"><a href="#八、activiti7进阶" class="header-anchor">#</a> 八、Activiti7进阶</h2> <h3 id="_8-1-流程定义相关"><a href="#_8-1-流程定义相关" class="header-anchor">#</a> 8.1 流程定义相关</h3> <h4 id="_8-1-1-流程定义查询-act-re-procdef"><a href="#_8-1-1-流程定义查询-act-re-procdef" class="header-anchor">#</a> 8.1.1 流程定义查询   act_re_procdef</h4> <ul><li>查询流程相关信息，包含流程定义，流程部署，流程定义版本</li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testDefinitionQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取仓库服务</span>
    <span class="token class-name">RepositoryService</span> repositoryService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRepositoryService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取流程定义集合</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ProcessDefinition</span><span class="token punctuation">&gt;</span></span> processDefinitionList <span class="token operator">=</span> repositoryService
            <span class="token punctuation">.</span><span class="token function">createProcessDefinitionQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveProcess&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//遍历集合</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">ProcessDefinition</span> definition<span class="token operator">:</span>processDefinitionList<span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义ID:&quot;</span><span class="token operator">+</span>definition<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义名称:&quot;</span><span class="token operator">+</span>definition<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义key:&quot;</span><span class="token operator">+</span>definition<span class="token punctuation">.</span><span class="token function">getKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义版本:&quot;</span><span class="token operator">+</span>definition<span class="token punctuation">.</span><span class="token function">getVersion</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署ID:&quot;</span><span class="token operator">+</span>definition<span class="token punctuation">.</span><span class="token function">getDeploymentId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;====================&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br></div></div><h4 id="_8-1-2-流程资源下载"><a href="#_8-1-2-流程资源下载" class="header-anchor">#</a> 8.1.2 流程资源下载</h4> <ul><li><p>现在我们的流程资源文件已经上传到数据库了，如果其他用户想要查看这些资源文件，可以从数据库中把资源文件下载到本地。</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testDownloadResource</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取仓库服务</span>
    <span class="token class-name">RepositoryService</span> repositoryService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRepositoryService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取流程定义集合</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ProcessDefinition</span><span class="token punctuation">&gt;</span></span> list <span class="token operator">=</span> repositoryService
            <span class="token punctuation">.</span><span class="token function">createProcessDefinitionQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveProcess&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">orderByProcessDefinitionVersion</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token comment">//按照版本排序</span>
            <span class="token punctuation">.</span><span class="token function">desc</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token comment">//降序</span>
            <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取最新那个</span>
    <span class="token class-name">ProcessDefinition</span> definition <span class="token operator">=</span>list<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取部署ID</span>
    <span class="token class-name">String</span> deploymentId <span class="token operator">=</span> definition<span class="token punctuation">.</span><span class="token function">getDeploymentId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取bpmn的输入流</span>
    <span class="token class-name">InputStream</span> bpmnInput <span class="token operator">=</span> repositoryService<span class="token punctuation">.</span><span class="token function">getResourceAsStream</span><span class="token punctuation">(</span>
                                        deploymentId<span class="token punctuation">,</span>
                                        definition<span class="token punctuation">.</span><span class="token function">getResourceName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取png的输入流</span>
    <span class="token class-name">InputStream</span> pngInput <span class="token operator">=</span> repositoryService<span class="token punctuation">.</span><span class="token function">getResourceAsStream</span><span class="token punctuation">(</span>
                                        deploymentId<span class="token punctuation">,</span>
                                        definition<span class="token punctuation">.</span><span class="token function">getDiagramResourceName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//设置bpmn输入</span>
    <span class="token class-name">FileOutputStream</span> bpmnOutPut <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FileOutputStream</span><span class="token punctuation">(</span><span class="token string">&quot;D:/leave.bpmn&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//设置png输入</span>
    <span class="token class-name">FileOutputStream</span> pngOutPut <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FileOutputStream</span><span class="token punctuation">(</span><span class="token string">&quot;D:/leave.png&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">IOUtils</span><span class="token punctuation">.</span><span class="token function">copy</span><span class="token punctuation">(</span>bpmnInput<span class="token punctuation">,</span>bpmnOutPut<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">IOUtils</span><span class="token punctuation">.</span><span class="token function">copy</span><span class="token punctuation">(</span>pngInput<span class="token punctuation">,</span>pngOutPut<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br></div></div></li></ul> <h4 id="_8-1-3-流程定义删除"><a href="#_8-1-3-流程定义删除" class="header-anchor">#</a> 8.1.3 流程定义删除</h4> <ul><li>根据部署Id删除对应的流程定义</li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testDeleteDeploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//流程部署Id</span>
    <span class="token class-name">String</span> deploymentId <span class="token operator">=</span> <span class="token string">&quot;10001&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取仓库服务</span>
    <span class="token class-name">RepositoryService</span> repositoryService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRepositoryService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//删除流程定义，如果该流程定义已有流程实例启动则删除时出错</span>
    repositoryService<span class="token punctuation">.</span><span class="token function">deleteDeployment</span><span class="token punctuation">(</span>deploymentId<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//设置true 级联删除流程定义，即使该流程有流程实例启动也可以删除，设置为false非级别删除方式，如果流程</span>
    <span class="token comment">//repositoryService.deleteDeployment(deploymentId,true);</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div><p>说明：</p> <ol><li><p>如果该流程定义下没有正在运行的流程，则可以用普通删除。</p></li> <li><p>如果该流程定义下存在已经运行的流程，使用普通删除报错，可用级联删除方法将流程及相关记录全部删除。</p></li> <li><p>项目开发中级联删除操作一般只开放给超级管理员使用.</p></li></ol> <h3 id="_8-2-流程实例相关"><a href="#_8-2-流程实例相关" class="header-anchor">#</a> 8.2 流程实例相关</h3> <h4 id="_8-2-1-什么是流程实例"><a href="#_8-2-1-什么是流程实例" class="header-anchor">#</a> 8.2.1 什么是流程实例</h4> <p>用户或程序按照流程定义内容发起一个流程，这就是一个流程实例。</p> <p>流程定义和流程实例的图解：</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210602172050824.png" alt=""></strong></p> <h4 id="_8-2-2-businesskey-业务标识"><a href="#_8-2-2-businesskey-业务标识" class="header-anchor">#</a> 8.2.2 BusinessKey（业务标识）</h4> <ol><li>小张要在5.1~5.10这段时间请假,请假理由为:回家相亲.</li> <li>小陈要在5.5~5.15这段时间请假,请假理由为:家里拆迁,回家办手续.</li></ol> <p>请问会创建几个流程实例?</p> <p>流程发起之后，目前设定的部门审批人都是李四，李四在审批之前需要看到申请人申请的时间和申请的理由，才能决定是否同意.</p> <p>那么申请人的请假信息【请假时间、请假理由】是如何绑定到流程中的呢?</p> <p>此时就需要使用到<code>BusinessKey</code></p> <ul><li>启动流程实例时，指定的businessKey，就会在act_run_execution表中存储businessKey。</li> <li>BusinessKey：业务标识，通常为业务表的主键，业务标识和流程实例一一对应。业务标识来源于业务系统。存储业务标识就是根据业务标识来关联查询业务系统的数据。比如：请假流程启动一个流程实例，就可以将请假单的id作为业务标识存储到Activiti中，将来查询Activiti的流程实例信息就可以获取请假单的id从而关联查询业务系统数据库得到请假单信息。</li></ul> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/businesskey.png" alt=""></strong></p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testStartProcess</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token class-name">String</span> businessKey <span class="token operator">=</span> <span class="token string">&quot;8001&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取RuntimeService对象</span>
    <span class="token class-name">RuntimeService</span> runtimeService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRuntimeService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//根据流程定义的key启动流程实例,这个key是在定义bpmn的时候设置的</span>
    <span class="token comment">//在启动流程的时候将业务key加入进去</span>
    <span class="token class-name">ProcessInstance</span> instance <span class="token operator">=</span> runtimeService
            <span class="token punctuation">.</span><span class="token function">startProcessInstanceByKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveProcess&quot;</span><span class="token punctuation">,</span>businessKey<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取流程实例的相关信息</span>
    <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><p>观察数据库可以发现，在activiti的act_ru_execution表，字段BUSINESS_KEY就是存放业务KEY的。</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210603094635615.png" alt=""></strong></p> <ul><li>在用户执行任务的时候如何获取<code>BusinessKey</code>并关联对应的业务信息呢?</li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testGetBusinessKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//任务负责人</span>
    <span class="token class-name">String</span> assignee <span class="token operator">=</span> <span class="token string">&quot;李四&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取TaskService</span>
    <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取RuntimeService</span>
    <span class="token class-name">RuntimeService</span> runtimeService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRuntimeService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取任务集合</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Task</span><span class="token punctuation">&gt;</span></span> taskList <span class="token operator">=</span> taskService<span class="token punctuation">.</span><span class="token function">createTaskQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveProcess&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span>assignee<span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//遍历任务列表</span>
    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token operator">:</span>taskList<span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getProcessInstanceId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务名称 = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//根据任务上的流程实例Id查询出对应的流程实例对象，从流程实例对象中获取BusinessKey</span>
        <span class="token class-name">ProcessInstance</span> instance <span class="token operator">=</span> runtimeService
                <span class="token punctuation">.</span><span class="token function">createProcessInstanceQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">processInstanceId</span><span class="token punctuation">(</span>task<span class="token punctuation">.</span><span class="token function">getProcessInstanceId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">singleResult</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;业务key:&quot;</span><span class="token operator">+</span>instance<span class="token punctuation">.</span><span class="token function">getBusinessKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;===================&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br></div></div><h4 id="_8-2-3-流程定义-实例挂起-激活"><a href="#_8-2-3-流程定义-实例挂起-激活" class="header-anchor">#</a> 8.2.3 流程定义/实例挂起/激活</h4> <p>activitaProcessDefinitionById</p> <p>suspendProcessDefinitionById</p> <p><strong>全部流程实例挂起场景</strong>:</p> <ol><li><p>例如公司制度改变过程中的流程, 总经理更换过程中的流程，有100个人的流程, 70个人已经完成,30个人流程正好在总经理更换中,就需要挂起.</p></li> <li><p>比如我们的业务流程为:</p></li></ol> <p>【开始节点】--&gt;【A节点】--&gt;【B节点】--&gt;【C节点】--&gt;【结束节点】</p> <p>【C节点】的业务逻辑需要和外部接口交互，刚好外部接口出问题了,如果剩下的流程都走到【C节点】，执行【C节点】的业务逻辑，那都会报错，我们就可以把流程挂起，等待外部接口可用之后再重新激活流程.</p> <ol start="3"><li>业务流程发生改变,已经发起的流程实例继续按照旧的流程走,如果新发起的流程就按照新的业务流程走.这时候我们就需要挂起流程定义,但是不挂起流程实例.</li></ol> <ul><li>操作流程定义为挂起状态，该操作定义下面的所有的流程实例将全部暂停。</li> <li>流程定义为挂起状态，该流程定义下将不允许启动新的流程实例，同时该流程定义下的所有流程实例将全部挂起暂停执行</li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testSuspendAllProcessInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取RepositoryService</span>
    <span class="token class-name">RepositoryService</span> repositoryService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRepositoryService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取流程定义对象</span>
    <span class="token class-name">ProcessDefinition</span> processDefinition <span class="token operator">=</span> repositoryService
            <span class="token punctuation">.</span><span class="token function">createProcessDefinitionQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveProcess&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">singleResult</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">boolean</span> suspended <span class="token operator">=</span> processDefinition<span class="token punctuation">.</span><span class="token function">isSuspended</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//输出流程定义状态</span>
    <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义状态:&quot;</span><span class="token operator">+</span><span class="token punctuation">(</span>suspended <span class="token operator">?</span><span class="token string">&quot;已挂起&quot;</span><span class="token operator">:</span><span class="token string">&quot;已激活&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> processDefinitionId <span class="token operator">=</span> processDefinition<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>suspended<span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//如果是挂起，可以执行激活操作 ,参数1 ：流程定义id ，参数2：是否激活流程实例，参数3：激活时间</span>
        repositoryService<span class="token punctuation">.</span><span class="token function">activateProcessDefinitionById</span><span class="token punctuation">(</span>processDefinitionId<span class="token punctuation">,</span><span class="token boolean">true</span><span class="token punctuation">,</span><span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程ID:&quot;</span><span class="token operator">+</span>processDefinitionId<span class="token operator">+</span><span class="token string">&quot;,已激活&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
        <span class="token comment">//如果是激活，可以执行挂起操作 ,参数1 ：流程定义id ，参数2：是否暂停流程实例，参数3：激活时间</span>
        repositoryService<span class="token punctuation">.</span><span class="token function">suspendProcessDefinitionById</span><span class="token punctuation">(</span>processDefinitionId<span class="token punctuation">,</span><span class="token boolean">true</span><span class="token punctuation">,</span><span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程ID:&quot;</span><span class="token operator">+</span>processDefinitionId<span class="token operator">+</span><span class="token string">&quot;,已挂起&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><ul><li>查询待办任务的状态,如果是【已挂起】,前台则不允许点击【任务处理】按钮</li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testSuspendStatus</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//任务负责人</span>
    <span class="token class-name">String</span> assignee <span class="token operator">=</span> <span class="token string">&quot;李四&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取TaskService</span>
    <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取任务集合</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Task</span><span class="token punctuation">&gt;</span></span> taskList <span class="token operator">=</span> taskService<span class="token punctuation">.</span><span class="token function">createTaskQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveProcess&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span>assignee<span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//遍历任务列表</span>
    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token operator">:</span>taskList<span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getProcessInstanceId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务名称 = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务状态:&quot;</span><span class="token operator">+</span><span class="token punctuation">(</span>task<span class="token punctuation">.</span><span class="token function">isSuspended</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">?</span><span class="token string">&quot;已挂起&quot;</span><span class="token operator">:</span><span class="token string">&quot;已激活&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;===================&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br></div></div><ul><li><p>利用之前的测试用例，测试在流程挂起的情况是否能发起新的流程实例</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token class-name"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span>ActivitiException</span><span class="token operator">:</span> <span class="token class-name">Cannot</span> start process <span class="token class-name"><span class="token namespace">instance<span class="token punctuation">.</span></span> Process</span> definition 请假流程 <span class="token punctuation">(</span>id <span class="token operator">=</span> leaveProcess<span class="token operator">:</span><span class="token number">1</span><span class="token operator">:</span><span class="token number">4</span><span class="token punctuation">)</span> is suspended
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>利用之前的测试用例，测试在流程挂起的情况是否可以处理任务</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token class-name"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span>ActivitiException</span><span class="token operator">:</span> <span class="token class-name">Cannot</span> complete a suspended task
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li></ul> <p><strong>单个流程实例挂起场景</strong></p> <p>评分流程：可设置多级评分，评分流程会按照从上往下的顺序，依次评分；评分人必须在评分截至时间内完成评分，否则不允许继续评分，流程将会挂起，停止流转；</p> <ul><li>操作流程实例对象，针对单个流程执行挂起操作，某个流程实例挂起则此流程不再执行，完成该流程实例的当前任务将报异常。</li></ul> <p>查询所有的流程实例</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testQueryProcessInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取RepositoryService</span>
    <span class="token class-name">RuntimeService</span> runtimeService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRuntimeService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ProcessInstance</span><span class="token punctuation">&gt;</span></span> processInstanceList <span class="token operator">=</span> runtimeService
            <span class="token punctuation">.</span><span class="token function">createProcessInstanceQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveProcess&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">ProcessInstance</span> processInstance<span class="token operator">:</span>processInstanceList<span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例Id:&quot;</span><span class="token operator">+</span>processInstance<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">+</span><span class="token string">&quot;,状态:&quot;</span><span class="token operator">+</span><span class="token punctuation">(</span>processInstance<span class="token punctuation">.</span><span class="token function">isSuspended</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">?</span><span class="token string">&quot;已挂起&quot;</span><span class="token operator">:</span><span class="token string">&quot;已激活&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p>挂起某个流程实例</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testSuspendSingleProcessInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//流程实例Id</span>
    <span class="token class-name">String</span> processInstanceId <span class="token operator">=</span> <span class="token string">&quot;2501&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取RepositoryService</span>
    <span class="token class-name">RuntimeService</span> runtimeService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRuntimeService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//根据流程实例Id获取流程实例对象</span>
    <span class="token class-name">ProcessInstance</span> processInstance <span class="token operator">=</span> runtimeService
            <span class="token punctuation">.</span><span class="token function">createProcessInstanceQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">processInstanceId</span><span class="token punctuation">(</span>processInstanceId<span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">singleResult</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//状态</span>
    <span class="token keyword">boolean</span> suspended <span class="token operator">=</span> processInstance<span class="token punctuation">.</span><span class="token function">isSuspended</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例ID:&quot;</span><span class="token operator">+</span>processInstanceId<span class="token operator">+</span><span class="token string">&quot;,状态:&quot;</span><span class="token operator">+</span> <span class="token punctuation">(</span>suspended<span class="token operator">?</span><span class="token string">&quot;已挂起&quot;</span><span class="token operator">:</span><span class="token string">&quot;已激活&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>suspended<span class="token punctuation">)</span><span class="token punctuation">{</span>
        runtimeService<span class="token punctuation">.</span><span class="token function">activateProcessInstanceById</span><span class="token punctuation">(</span>processInstanceId<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例ID:&quot;</span><span class="token operator">+</span>processInstanceId<span class="token operator">+</span><span class="token string">&quot;,状态修改为已激活&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
        runtimeService<span class="token punctuation">.</span><span class="token function">suspendProcessInstanceById</span><span class="token punctuation">(</span>processInstanceId<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例ID:&quot;</span><span class="token operator">+</span>processInstanceId<span class="token operator">+</span><span class="token string">&quot;,状态修改为已挂起&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br></div></div><h3 id="_8-3-任务分配负责人"><a href="#_8-3-任务分配负责人" class="header-anchor">#</a> 8.3 任务分配负责人</h3> <h4 id="_8-3-1-固定分配"><a href="#_8-3-1-固定分配" class="header-anchor">#</a> 8.3.1 固定分配</h4> <ul><li><p>在进行业务流程建模的时候指定固定的任务负责人。</p> <p><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub//image-20210602170718364.png" alt=""></p></li></ul> <h4 id="_8-3-2-uel表达式分配"><a href="#_8-3-2-uel表达式分配" class="header-anchor">#</a> 8.3.2 UEL表达式分配</h4> <p>Activiti 使用 UEL 表达式， UEL 是 java EE6 规范的一部分， UEL（Unified Expression Language）即 统一表达式语言。</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210603111807021.png" alt=""></strong></p> <p>IDEA中的actiBPM插件在修改Assignee存在bug,在界面上修改了,但是实际文件并没有修改.所以我们需要借助编辑工具在xml文件中修改一下Assignee</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210603112033041.png" alt=""></strong></p> <ul><li><p>修改流程定义之后重新进行部署</p></li> <li><p>编写代码配置负责人</p></li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testStartProcess</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取RuntimeService对象</span>
    <span class="token class-name">RuntimeService</span> runtimeService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRuntimeService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> variables  <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    variables<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;assignee0&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;zhangsan&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    variables<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;assignee1&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;lisi&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//根据流程定义的key启动流程实例,这个key是在定义bpmn的时候设置的</span>
    <span class="token class-name">ProcessInstance</span> instance <span class="token operator">=</span> runtimeService
            <span class="token punctuation">.</span><span class="token function">startProcessInstanceByKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveProcess&quot;</span><span class="token punctuation">,</span>variables<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取流程实例的相关信息</span>
    <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><p>执行成功后，可以在act_ru_variable表中看到刚才map中的数据</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210603112843933.png" alt=""></strong></p> <h4 id="_8-3-3-监听器分配【拓展】"><a href="#_8-3-3-监听器分配【拓展】" class="header-anchor">#</a> 8.3.3 监听器分配【拓展】</h4> <ul><li>任务监听器是发生对应的任务相关事件时执行自定义的Java逻辑或表达式。</li> <li>任务相关事件包括：
<ul><li>Event：
<ul><li>Create：任务创建后触发。</li> <li>Assignment：任务分配后触发。</li> <li>Delete：任务完成后触发。</li> <li>All：所有事件发生都触发。</li></ul></li></ul></li></ul> <ol><li><p>自定义一个任务监听器类，然后此类必须实现org.activiti.engine.delegate.TaskListener接口</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">cn<span class="token punctuation">.</span>wolfcode</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>delegate<span class="token punctuation">.</span></span><span class="token class-name">DelegateTask</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>delegate<span class="token punctuation">.</span></span><span class="token class-name">TaskListener</span></span><span class="token punctuation">;</span>

<span class="token comment">/**
 * Created by wolfcode
 */</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">AssigneeTaskListener</span> <span class="token keyword">implements</span> <span class="token class-name">TaskListener</span> <span class="token punctuation">{</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">notify</span><span class="token punctuation">(</span><span class="token class-name">DelegateTask</span> delegateTask<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>delegateTask<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span><span class="token string">&quot;部门经理审批&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
            delegateTask<span class="token punctuation">.</span><span class="token function">setAssignee</span><span class="token punctuation">(</span><span class="token string">&quot;赵六&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token keyword">if</span><span class="token punctuation">(</span>delegateTask<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span><span class="token string">&quot;部门经理审批&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
            delegateTask<span class="token punctuation">.</span><span class="token function">setAssignee</span><span class="token punctuation">(</span><span class="token string">&quot;孙七&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div></li> <li><p>在bpmn文件中配置监听器</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210603114503828.png" alt=""></strong></p></li></ol> <ul><li>在实际开发中，一般也不使用监听器分配方式，太麻烦了。</li></ul> <h3 id="_8-4-流程变量"><a href="#_8-4-流程变量" class="header-anchor">#</a> 8.4 流程变量</h3> <h4 id="_8-4-1-什么是流程变量"><a href="#_8-4-1-什么是流程变量" class="header-anchor">#</a> 8.4.1 什么是流程变量？</h4> <ul><li>流程变量在Activiti中是一个非常重要的角色，流程运转有时需要靠流程变量，业务系统和Activiti结合时少不了流程变量，流程变量就是Activiti在管理工作流时根据管理需要而设置的变量。</li> <li>比如在请假流程流转时如果请假天数&gt;3天则有总经理审批，否则由人事直接审批，请假天数就可以设置流程变量，在流程流转时使用。</li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code>注意：虽然流程变量中可以存储业务数据，可以通过Activiti的API查询流程变量从而实现查询业务数据，但是不建议这么使用，因为业务数据查询由业务系统负责，Activiti设置流程变量是为了流程执行需要而创建的。
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="_8-4-2-流程变量类型"><a href="#_8-4-2-流程变量类型" class="header-anchor">#</a> 8.4.2 流程变量类型</h4> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/variableTypes.png" alt=""></strong></p> <div class="language- line-numbers-mode"><pre class="language-text"><code>注意：
如果将POJO存储到流程变量中，必须实现序列化接口Serializable，为了防止由于新增字段无法反序列化。
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h4 id="_8-4-3-流程变量的作用域"><a href="#_8-4-3-流程变量的作用域" class="header-anchor">#</a> 8.4.3 流程变量的作用域</h4> <p>流程变量的作用域范围可以是一个流程实例（ProcessInstance）、一个任务（Task）或一个执行实例（Execution）。</p> <ul><li>global变量: 流程变量的作用域范围的默认值是流程实例，作用域范围最大。</li> <li>local变量   : 流程变量的作用域范围如果仅仅针对一个任务或一个执行实例，那么作用域范围没有流程实例大</li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code>实际开发中一般不用local变量，了解即可.
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h4 id="_8-4-4-流程变量的使用方法"><a href="#_8-4-4-流程变量的使用方法" class="header-anchor">#</a> 8.4.4 流程变量的使用方法</h4> <ul><li><p>在属性上使用UEL表达式</p> <p>可以在 assignee 处设置 UEL 表达式，表达式的值为任务的负责人，比如： ${assignee}， assignee 就是一个流程变量名称。</p> <p>Activiti获取UEL表达式的值，即流程变量assignee的值 ，将assignee的值作为任务的负责人进行任务分配</p></li> <li><p>在连线上使用UEL表达式</p> <p>可以在连线上设置UEL表达式，决定流程走向。</p> <p>比如：${price&lt;10000} 。price就是一个流程变量名称，uel表达式结果类型为布尔类型。</p> <p>如果UEL表达式是true，要决定 流程执行走向。</p></li></ul> <h4 id="_8-4-5-使用global变量控制流程"><a href="#_8-4-5-使用global变量控制流程" class="header-anchor">#</a> 8.4.5 使用global变量控制流程</h4> <p>需求:员工创建请假流程申请单，由部门经理审批，部门经理审批通过后请假3天以下(含3天)的由人事经理直接审批，3天以上的由总经理审批，总经理审批通过再通过人事经理审批。</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210603131447915.png" alt=""></strong></p> <ul><li>在连线处添加判断条件</li></ul> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210603131830958.png" alt=""></strong></p> <div class="language- line-numbers-mode"><pre class="language-text"><code>本次画BPMN文件的时候将部门经理的assignee设置为李四，总经理审批的assignee设置为王五，总经理审批的assignee设置为王五，人事复批存档设置为赵六。
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">cn<span class="token punctuation">.</span>wolfcode<span class="token punctuation">.</span>demo</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>repository<span class="token punctuation">.</span></span><span class="token class-name">Deployment</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>runtime<span class="token punctuation">.</span></span><span class="token class-name">ProcessInstance</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>task<span class="token punctuation">.</span></span><span class="token class-name">Task</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>junit<span class="token punctuation">.</span></span><span class="token class-name">Test</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">HashMap</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Map</span></span><span class="token punctuation">;</span>

<span class="token comment">/**
 * Created by wolfcode
 */</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">VariablesTest</span> <span class="token punctuation">{</span>

    <span class="token comment">/**
     * 部署
     */</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testDeploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取RepositoryService对象</span>
        <span class="token class-name">RepositoryService</span> repositoryService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRepositoryService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//进行部署</span>
        <span class="token class-name">Deployment</span> deployment <span class="token operator">=</span> repositoryService<span class="token punctuation">.</span><span class="token function">createDeployment</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">addClasspathResource</span><span class="token punctuation">(</span><span class="token string">&quot;bpmn/leave-variables.bpmn&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token string">&quot;请假流程&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">deploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//输出部署的一些信息</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署ID:&quot;</span><span class="token operator">+</span>deployment<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署名称:&quot;</span><span class="token operator">+</span>deployment<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testStartProcess</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取RuntimeService对象</span>
        <span class="token class-name">RuntimeService</span> runtimeService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRuntimeService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> variables <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        variables<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;day&quot;</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//根据流程定义的key启动流程实例,这个key是在定义bpmn的时候设置的</span>
        <span class="token class-name">ProcessInstance</span> instance <span class="token operator">=</span> runtimeService<span class="token punctuation">.</span><span class="token function">startProcessInstanceByKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveVariablesProcess&quot;</span><span class="token punctuation">,</span>variables<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取流程实例的相关信息</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testSelectTodoTaskList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//任务负责人</span>
        <span class="token class-name">String</span> assignee <span class="token operator">=</span> <span class="token string">&quot;李四&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取TaskService</span>
        <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取任务集合</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Task</span><span class="token punctuation">&gt;</span></span> taskList <span class="token operator">=</span> taskService<span class="token punctuation">.</span><span class="token function">createTaskQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveVariablesProcess&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span>assignee<span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//遍历任务列表</span>
        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token operator">:</span>taskList<span class="token punctuation">)</span><span class="token punctuation">{</span>
            <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getProcessInstanceId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务名称 = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testCompleteTask</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//任务负责人</span>
        <span class="token class-name">String</span> assignee <span class="token operator">=</span> <span class="token string">&quot;李四&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取TaskService</span>
        <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取任务集合</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Task</span><span class="token punctuation">&gt;</span></span> taskList <span class="token operator">=</span> taskService<span class="token punctuation">.</span><span class="token function">createTaskQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveVariablesProcess&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span>assignee<span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//遍历任务列表</span>
        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token operator">:</span>taskList<span class="token punctuation">)</span><span class="token punctuation">{</span>
            taskService<span class="token punctuation">.</span><span class="token function">complete</span><span class="token punctuation">(</span>task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br></div></div><p><strong>注意事项</strong>:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>1.如果UEL表达式中流程变量名不存在则报错。
2.如果如果UEL表达式都不符合条件,流程报错。
3.如果连接不设置条件/条件都满足,每个连线都会走.
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="_8-5-任务候选人"><a href="#_8-5-任务候选人" class="header-anchor">#</a> 8.5 任务候选人</h3> <p>在流程定义中在任务结点的 assignee 固定设置任务负责人，在流程定义时将参与者固定设置在.bpmn 文件中，如果临时任务负责人变更则需要修改流程定义，系统可扩展性差。</p> <p>针对这种情况可以给任务设置多个候选人，可以从候选人中选择参与者来完成任务。</p> <h4 id="_8-5-1-设置任务候选人"><a href="#_8-5-1-设置任务候选人" class="header-anchor">#</a> 8.5.1 设置任务候选人</h4> <ul><li><p>在流程图中任务节点的配置中设置 candidate-users(候选人)，多个候选人之间用逗号分开。</p> <p><strong><img src="%E5%9B%BE%E7%89%87/image-20210603140345361.png" alt="image-20210603140345361"></strong></p></li> <li><p>查看bpmn文件</p></li> <li><p>我们可以看到部门经理的审核人已经设置为 lisi,wangwu 这样的一组候选人，可以使用activiti:candiateUsers=”用户 1,用户 2,用户 3”的这种方式来实现设置一组候选人</p></li></ul> <h4 id="_8-5-2-部署-启动流程"><a href="#_8-5-2-部署-启动流程" class="header-anchor">#</a> 8.5.2 部署&amp;启动流程</h4> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">cn<span class="token punctuation">.</span>wolfcode<span class="token punctuation">.</span>demo</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>repository<span class="token punctuation">.</span></span><span class="token class-name">Deployment</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>runtime<span class="token punctuation">.</span></span><span class="token class-name">ProcessInstance</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>task<span class="token punctuation">.</span></span><span class="token class-name">Task</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>junit<span class="token punctuation">.</span></span><span class="token class-name">Test</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">HashMap</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Map</span></span><span class="token punctuation">;</span>

<span class="token comment">/**
 * Created by wolfcode
 */</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">CandidateTest</span> <span class="token punctuation">{</span>
    <span class="token comment">/**
     * 部署
     */</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testDeploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取RepositoryService对象</span>
        <span class="token class-name">RepositoryService</span> repositoryService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRepositoryService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//进行部署</span>
        <span class="token class-name">Deployment</span> deployment <span class="token operator">=</span> repositoryService<span class="token punctuation">.</span><span class="token function">createDeployment</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">addClasspathResource</span><span class="token punctuation">(</span><span class="token string">&quot;bpmn/leave-candidate.bpmn&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token string">&quot;请假流程-候选人&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">deploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//输出部署的一些信息</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署ID:&quot;</span><span class="token operator">+</span>deployment<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署名称:&quot;</span><span class="token operator">+</span>deployment<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">//启动流程</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testStartProcess</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取RuntimeService对象</span>
        <span class="token class-name">RuntimeService</span> runtimeService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRuntimeService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//根据流程定义的key启动流程实例,这个key是在定义bpmn的时候设置的</span>
        <span class="token class-name">ProcessInstance</span> instance <span class="token operator">=</span> runtimeService<span class="token punctuation">.</span><span class="token function">startProcessInstanceByKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveCandidateProcess&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取流程实例的相关信息</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br></div></div><h4 id="_8-5-3-查询候选人任务"><a href="#_8-5-3-查询候选人任务" class="header-anchor">#</a> 8.5.3 查询候选人任务</h4> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token comment">//查询候选任务</span>
<span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testSelectCandidateTaskList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//任务负责人</span>
    <span class="token class-name">String</span> candidateUser <span class="token operator">=</span> <span class="token string">&quot;李四&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取TaskService</span>
    <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取任务集合</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Task</span><span class="token punctuation">&gt;</span></span> taskList <span class="token operator">=</span> taskService<span class="token punctuation">.</span><span class="token function">createTaskQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveCandidateProcess&quot;</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">taskCandidateUser</span><span class="token punctuation">(</span>candidateUser<span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//遍历任务列表</span>
    <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token operator">:</span>taskList<span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getProcessInstanceId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务id = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;任务名称 = &quot;</span> <span class="token operator">+</span> task<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br></div></div><h4 id="_8-5-4-领取候选人任务"><a href="#_8-5-4-领取候选人任务" class="header-anchor">#</a> 8.5.4 领取候选人任务</h4> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testClaimTask</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//任务ID</span>
    <span class="token class-name">String</span> taskId <span class="token operator">=</span> <span class="token string">&quot;2505&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> assignee <span class="token operator">=</span> <span class="token string">&quot;张三&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取TaskService</span>
    <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//领取任务</span>
    taskService<span class="token punctuation">.</span><span class="token function">claim</span><span class="token punctuation">(</span>taskId<span class="token punctuation">,</span>assignee<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><h4 id="_8-5-4-完成任务"><a href="#_8-5-4-完成任务" class="header-anchor">#</a> 8.5.4 完成任务</h4> <p>如果候选任务没有进行领取就直接完成的话，那么在历史记录中就不会记录是哪个用户执行了这个任务.</p> <p>所以对于这种候选人的任务，我们需要先领取再完成.</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token comment">//执行任务</span>
<span class="token annotation punctuation">@Test</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testCompleteTask</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//任务ID</span>
    <span class="token class-name">String</span> taskId <span class="token operator">=</span> <span class="token string">&quot;2505&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//创建ProcessEngine对象</span>
    <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//获取TaskService</span>
    <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    taskService<span class="token punctuation">.</span><span class="token function">complete</span><span class="token punctuation">(</span>taskId<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><h3 id="_8-6-网关"><a href="#_8-6-网关" class="header-anchor">#</a> 8.6 网关</h3> <h4 id="_8-6-1-排他网关"><a href="#_8-6-1-排他网关" class="header-anchor">#</a> 8.6.1 排他网关</h4> <p>排他网关(ExclusiveGateway)（异或网关或基于数据的排他网关），用来在流程中实现决策。当流程执行到这个网关的时候，所有分支都会判断条件是否为true，如果为true则执行该分支。</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>注意：
排他网关只会选择一个为true的分支执行（即使有两个分支条件都为true，排他网关也只会选择一条分支去执行,选择序号小的路径执行）。
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210603144113187.png" alt=""></strong></p> <div class="language- line-numbers-mode"><pre class="language-text"><code>本次画BPMN文件的时候将部门经理的assignee设置为李四，总经理审批的assignee设置为王五，总经理审批的assignee设置为王五，人事复批存档设置为赵六。
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">cn<span class="token punctuation">.</span>wolfcode<span class="token punctuation">.</span>demo</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>repository<span class="token punctuation">.</span></span><span class="token class-name">Deployment</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>runtime<span class="token punctuation">.</span></span><span class="token class-name">ProcessInstance</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>task<span class="token punctuation">.</span></span><span class="token class-name">Task</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>junit<span class="token punctuation">.</span></span><span class="token class-name">After</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>junit<span class="token punctuation">.</span></span><span class="token class-name">Test</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">HashMap</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Map</span></span><span class="token punctuation">;</span>

<span class="token comment">/**
 * Created by wolfcode
 */</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">EGatewayTest</span> <span class="token punctuation">{</span>

    <span class="token comment">/**
     * 部署
     */</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testDeploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取RepositoryService对象</span>
        <span class="token class-name">RepositoryService</span> repositoryService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRepositoryService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//进行部署</span>
        <span class="token class-name">Deployment</span> deployment <span class="token operator">=</span> repositoryService<span class="token punctuation">.</span><span class="token function">createDeployment</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">addClasspathResource</span><span class="token punctuation">(</span><span class="token string">&quot;bpmn/leave-EGateway.bpmn&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token string">&quot;请假流程-排他网关&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">deploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//输出部署的一些信息</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署ID:&quot;</span><span class="token operator">+</span>deployment<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署名称:&quot;</span><span class="token operator">+</span>deployment<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testStartProcess</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取RuntimeService对象</span>
        <span class="token class-name">RuntimeService</span> runtimeService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRuntimeService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> variables <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        variables<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;day&quot;</span><span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//根据流程定义的key启动流程实例,这个key是在定义bpmn的时候设置的</span>
        <span class="token class-name">ProcessInstance</span> instance <span class="token operator">=</span> runtimeService<span class="token punctuation">.</span><span class="token function">startProcessInstanceByKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveEGatewayProcess&quot;</span><span class="token punctuation">,</span>variables<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取流程实例的相关信息</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testCompleteTask</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//任务负责人</span>
        <span class="token class-name">String</span> assignee <span class="token operator">=</span> <span class="token string">&quot;张三&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取TaskService</span>
        <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取任务集合</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Task</span><span class="token punctuation">&gt;</span></span> taskList <span class="token operator">=</span> taskService<span class="token punctuation">.</span><span class="token function">createTaskQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveEGatewayProcess&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span>assignee<span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//遍历任务列表</span>
        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token operator">:</span>taskList<span class="token punctuation">)</span><span class="token punctuation">{</span>
            taskService<span class="token punctuation">.</span><span class="token function">complete</span><span class="token punctuation">(</span>task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br></div></div><h4 id="_8-6-2-并行网关"><a href="#_8-6-2-并行网关" class="header-anchor">#</a> 8.6.2 并行网关</h4> <p>并行网关(InclusiveGateway)允许将流程分成多条分支，也可以把多条分支汇聚到一起，并行网关的功能是基于进入和外出的顺序流的。</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>并行网关不会解析条件。即使顺序流中定义了条件，也会被忽略
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210603145537438.png" alt=""></strong></p> <div class="language- line-numbers-mode"><pre class="language-text"><code>本次画BPMN文件的时候将技术经理的assignee设置为李四，项目经理审批的assignee设置为王五，人事复批的assignee设置为王五
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">cn<span class="token punctuation">.</span>wolfcode<span class="token punctuation">.</span>demo</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>repository<span class="token punctuation">.</span></span><span class="token class-name">Deployment</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>runtime<span class="token punctuation">.</span></span><span class="token class-name">ProcessInstance</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>task<span class="token punctuation">.</span></span><span class="token class-name">Task</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>junit<span class="token punctuation">.</span></span><span class="token class-name">Test</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">HashMap</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Map</span></span><span class="token punctuation">;</span>

<span class="token comment">/**
 * Created by wolfcode
 */</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">PGatewayTest</span> <span class="token punctuation">{</span>
    <span class="token comment">/**
     * 部署
     */</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testDeploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取RepositoryService对象</span>
        <span class="token class-name">RepositoryService</span> repositoryService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRepositoryService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//进行部署</span>
        <span class="token class-name">Deployment</span> deployment <span class="token operator">=</span> repositoryService<span class="token punctuation">.</span><span class="token function">createDeployment</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">addClasspathResource</span><span class="token punctuation">(</span><span class="token string">&quot;bpmn/leave-PGateway.bpmn&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token string">&quot;请假流程-并行网关&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">deploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//输出部署的一些信息</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署ID:&quot;</span><span class="token operator">+</span>deployment<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署名称:&quot;</span><span class="token operator">+</span>deployment<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testStartProcess</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取RuntimeService对象</span>
        <span class="token class-name">RuntimeService</span> runtimeService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRuntimeService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> variables <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//根据流程定义的key启动流程实例,这个key是在定义bpmn的时候设置的</span>
        <span class="token class-name">ProcessInstance</span> instance <span class="token operator">=</span> runtimeService<span class="token punctuation">.</span><span class="token function">startProcessInstanceByKey</span><span class="token punctuation">(</span><span class="token string">&quot;leavePGatewayProcess&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取流程实例的相关信息</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
	<span class="token comment">//完成任务</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testCompleteTask</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//任务负责人</span>
        <span class="token class-name">String</span> assignee <span class="token operator">=</span> <span class="token string">&quot;张三&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取TaskService</span>
        <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取任务集合</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Task</span><span class="token punctuation">&gt;</span></span> taskList <span class="token operator">=</span> taskService<span class="token punctuation">.</span><span class="token function">createTaskQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leavePGatewayProcess&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span>assignee<span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//遍历任务列表</span>
        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token operator">:</span>taskList<span class="token punctuation">)</span><span class="token punctuation">{</span>
            taskService<span class="token punctuation">.</span><span class="token function">complete</span><span class="token punctuation">(</span>task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br></div></div><h4 id="_8-6-3-包含网关"><a href="#_8-6-3-包含网关" class="header-anchor">#</a> 8.6.3 包含网关</h4> <p>包含网关可以看做是排他网关和并行网关的结合体。</p> <p>需求:出差申请大于3天需要由项目经理审批，小于3等于天由技术经理审批，出差申请必须经过人事助理审批。</p> <p><strong><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20210603153330174.png" alt=""></strong></p> <div class="language- line-numbers-mode"><pre class="language-text"><code>本次画BPMN文件的时候将技术经理的assignee设置为张三，项目经理的assignee设置为李四，人事助理的assignee设置为王五，人事复批存档设置为赵六。
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">cn<span class="token punctuation">.</span>wolfcode<span class="token punctuation">.</span>demo</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>repository<span class="token punctuation">.</span></span><span class="token class-name">Deployment</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>runtime<span class="token punctuation">.</span></span><span class="token class-name">ProcessInstance</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>activiti<span class="token punctuation">.</span>engine<span class="token punctuation">.</span>task<span class="token punctuation">.</span></span><span class="token class-name">Task</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>junit<span class="token punctuation">.</span></span><span class="token class-name">Test</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">HashMap</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Map</span></span><span class="token punctuation">;</span>

<span class="token comment">/**
 * Created by wolfcode
 */</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">IGatewayTest</span> <span class="token punctuation">{</span>

    <span class="token comment">/**
     * 部署
     */</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testDeploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取RepositoryService对象</span>
        <span class="token class-name">RepositoryService</span> repositoryService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRepositoryService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//进行部署</span>
        <span class="token class-name">Deployment</span> deployment <span class="token operator">=</span> repositoryService<span class="token punctuation">.</span><span class="token function">createDeployment</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">addClasspathResource</span><span class="token punctuation">(</span><span class="token string">&quot;bpmn/leave-IGateway.bpmn&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token string">&quot;请假流程-包含网关&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">deploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//输出部署的一些信息</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署ID:&quot;</span><span class="token operator">+</span>deployment<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署名称:&quot;</span><span class="token operator">+</span>deployment<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testStartProcess</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取RuntimeService对象</span>
        <span class="token class-name">RuntimeService</span> runtimeService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getRuntimeService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> variables <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        variables<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;day&quot;</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//根据流程定义的key启动流程实例,这个key是在定义bpmn的时候设置的</span>
        <span class="token class-name">ProcessInstance</span> instance <span class="token operator">=</span> runtimeService<span class="token punctuation">.</span><span class="token function">startProcessInstanceByKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveIGatewayProcess&quot;</span><span class="token punctuation">,</span>variables<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取流程实例的相关信息</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getProcessDefinitionId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例的id = &quot;</span> <span class="token operator">+</span> instance<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
	<span class="token comment">//完成任务</span>
    <span class="token annotation punctuation">@Test</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">testCompleteTask</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token comment">//任务负责人</span>
        <span class="token class-name">String</span> assignee <span class="token operator">=</span> <span class="token string">&quot;王五&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">//创建ProcessEngine对象</span>
        <span class="token class-name">ProcessEngine</span> processEngine <span class="token operator">=</span> <span class="token class-name">ProcessEngines</span><span class="token punctuation">.</span><span class="token function">getDefaultProcessEngine</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取TaskService</span>
        <span class="token class-name">TaskService</span> taskService <span class="token operator">=</span> processEngine<span class="token punctuation">.</span><span class="token function">getTaskService</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//获取任务集合</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Task</span><span class="token punctuation">&gt;</span></span> taskList <span class="token operator">=</span> taskService<span class="token punctuation">.</span><span class="token function">createTaskQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;leaveIGatewayProcess&quot;</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span>assignee<span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">list</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//遍历任务列表</span>
        <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token operator">:</span>taskList<span class="token punctuation">)</span><span class="token punctuation">{</span>
            taskService<span class="token punctuation">.</span><span class="token function">complete</span><span class="token punctuation">(</span>task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br></div></div><h2 id="九、api小结"><a href="#九、api小结" class="header-anchor">#</a> 九、API小结</h2> <div class="language-java line-numbers-mode"><pre class="language-java"><code>【<span class="token class-name">Deployment</span>】 
获取方式：
repositoryService<span class="token punctuation">.</span><span class="token function">createDeployment</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">deploy</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
对应的表：act_re_deployment
核心字段：
id name deployementTime   category key  tenantid
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><div class="language-java line-numbers-mode"><pre class="language-java"><code>【<span class="token class-name">ProcessDefinition</span>】 
获取方式：
repositoryService<span class="token punctuation">.</span><span class="token function">createProcessDefinitionQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">deploymentId</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署id&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processDefinitionId</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义id&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的key&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processDefinitionName</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的name&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">singleResult</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
对应的表：act_re_procdef
核心字段：
id name key description  resourceName  deploymentId  tenantId  engineVersion

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><div class="language-java line-numbers-mode"><pre class="language-java"><code>【<span class="token class-name">ProcessInstance</span>】  
获取方式：
方式<span class="token number">1</span>：runtimeService<span class="token punctuation">.</span><span class="token function">startProcessInstanceByKey</span><span class="token punctuation">(</span>processDefinitionKey<span class="token punctuation">)</span><span class="token punctuation">;</span>
方式<span class="token number">2</span>：
runtimeService<span class="token punctuation">.</span><span class="token function">createProcessInstanceQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processInstanceId</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例id&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processDefinitionId</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义id&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的key&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">deploymentId</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署id&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processDefinitionName</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的name&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processInstanceBusinessKey</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例业务key&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">singleResult</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

对应的表：act_hi_procinst
核心字段：
name businessKey deploymentId description name processDefinitionId processDefinitionKey
processDefinitionName  startTime  startTimeUser  tenantId  activityId   processInstanceId

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><div class="language-java line-numbers-mode"><pre class="language-java"><code>【<span class="token class-name">Task</span>】  
获取方式：
taskService<span class="token punctuation">.</span><span class="token function">createTaskQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">taskId</span><span class="token punctuation">(</span><span class="token string">&quot;taskId&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span><span class="token string">&quot;节点任务负责人&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">taskCandidateUser</span><span class="token punctuation">(</span><span class="token string">&quot;taskCandidateUser&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">taskDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;taskDefinitionKey&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的key&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processInstanceId</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例id&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">deploymentId</span><span class="token punctuation">(</span><span class="token string">&quot;流程部署id&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">singleResult</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
对应的表：act_ru_task  
核心字段：
name description priority  owner assignee delegationState  formKey  parentTaskId
processInstanceId  executionId  processDefinitionId  processVariables

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><div class="language-java line-numbers-mode"><pre class="language-java"><code>【<span class="token class-name">HistoricActivityInstance</span>】  
获取方式：
historyService<span class="token punctuation">.</span><span class="token function">createHistoricActivityInstanceQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processDefinitionId</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义id&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">taskAssignee</span><span class="token punctuation">(</span><span class="token string">&quot;节点任务负责人&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processInstanceId</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例id&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">singleResult</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
对应的表：act_hi_actinst
核心字段：
id   activityId activityName  activityType  processDefinitionId  processInstanceId  
executionId  taskId   assignee   startTime  endTime  durationInMilli tenantId
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><div class="language-java line-numbers-mode"><pre class="language-java"><code>【<span class="token class-name">Execution</span>】
获取方式：
runtimeService<span class="token punctuation">.</span><span class="token function">createExecutionQuery</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的key&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">executionId</span><span class="token punctuation">(</span><span class="token string">&quot;executionId&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processDefinitionId</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义id&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processInstanceId</span><span class="token punctuation">(</span><span class="token string">&quot;流程实例id&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">processDefinitionKey</span><span class="token punctuation">(</span><span class="token string">&quot;流程定义的key&quot;</span><span class="token punctuation">)</span>
	<span class="token punctuation">.</span><span class="token function">singleResult</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
对应的表：act_ru_execution
核心字段：
id  activityId  processInstanceId  name  description
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><div class="language-java line-numbers-mode"><pre class="language-java"><code>【<span class="token class-name">IdentityLink</span>】   
获取方式：
方式<span class="token number">1</span>：runtimeService<span class="token punctuation">.</span><span class="token function">getIdentityLinksForProcessInstance</span><span class="token punctuation">(</span>processInstanceId<span class="token punctuation">)</span>
方式<span class="token number">2</span>：repositoryService<span class="token punctuation">.</span><span class="token function">getIdentityLinksForProcessDefinition</span><span class="token punctuation">(</span><span class="token class-name">ProcessDefinitionId</span><span class="token punctuation">)</span>
方式<span class="token number">3</span>：taskService<span class="token punctuation">.</span><span class="token function">getIdentityLinksForTask</span><span class="token punctuation">(</span>taskId<span class="token punctuation">)</span>
对应的表：act_ru_identitylink
核心字段：
type  userId   taskId   processDefinitionId  processInstanceId
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h2 id="_10、小结与作业"><a href="#_10、小结与作业" class="header-anchor">#</a> 10、小结与作业</h2> <h3 id="_10-1-小结"><a href="#_10-1-小结" class="header-anchor">#</a> 10.1 小结</h3> <ul><li>工作流概念</li> <li>activiti7 概念</li> <li>activiti7工具配置</li> <li>activiti7集成</li> <li>activiti7操作步骤</li> <li>流程定义对象查询/资源下载/删除</li> <li>流程实例查询/businesskey/挂起/激活</li> <li>任务负责人变量-uel设置</li> <li>流程变量-流程分支操作</li> <li>任务候选人设置/候选人查询/候选任务领取/放弃候选任务</li> <li>排他网关/并行网关/包含网关</li></ul> <h3 id="_10-2-作业"><a href="#_10-2-作业" class="header-anchor">#</a> 10.2 作业</h3> <p>绘制并代码执行</p> <p><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20240311224536013.png" alt=""></p> <p><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20240311224550413.png" alt=""></p> <p><img src="https://cdn.jsdelivr.net/gh/langfeiyes/images-khub/image-20240311224606302.png" alt=""></p></div></div>  <div class="page-edit"><!----> <div class="tags"><a href="/tags/?tag=activiti7" title="标签">#activiti7</a></div> <!----></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/pages/eed55d/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">脚手架-RuoYi-Cloud 微服务版</div></a> <a href="/pages/ca48f7/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">Git版本控制</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/pages/eed55d/" class="prev">脚手架-RuoYi-Cloud 微服务版</a></span> <span class="next"><a href="/pages/ca48f7/">Git版本控制</a>→
      </span></p></div></div></div> <div class="article-list"><div class="article-title"><a href="/archives/" class="iconfont icon-bi">最近更新</a></div> <div class="article-wrapper"><dl><dd>01</dd> <dt><a href="/pages/0c07b2/"><div>
            IT杂货铺
            <!----></div></a> <span class="date">03-23</span></dt></dl><dl><dd>02</dd> <dt><a href="/pages/705b35/"><div>
            人事百问
            <!----></div></a> <span class="date">03-22</span></dt></dl><dl><dd>03</dd> <dt><a href="/pages/78eb56/"><div>
            MyBatis-Plus
            <!----></div></a> <span class="date">03-12</span></dt></dl> <dl><dd></dd> <dt><a href="/archives/" class="more">更多文章&gt;</a></dt></dl></div></div></main></div> <div class="footer"><div class="icons"><a href="mailto:langfeiyes@163.com" title="发邮件" target="_blank" class="iconfont icon-youjian"></a><a href="https://github.com/langfeiyes" title="GitHub" target="_blank" class="iconfont icon-github"></a><a href="https://music.163.com/#/playlist?id=755597173" title="听音乐" target="_blank" class="iconfont icon-erji"></a></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2024-2024
    <span><a href="https://beian.miit.gov.cn/" target="_blank">粤ICP备18007927号-1</a></span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"><div></div></div></div>
    <script src="/assets/js/app.a2a00aa5.js" defer></script><script src="/assets/js/2.256f807a.js" defer></script><script src="/assets/js/67.f36b2f7d.js" defer></script>
  </body>
</html>
